<\/div>\n\n\n\n
\u82f1\u6587\u539f\u6587\u5982\u4e0b<\/strong><\/p>\n\n\n\nThere are two sisters Alice and Betty. You have\u00a0n<\/em><\/strong> candies. You want to distribute these\u00a0n<\/em><\/strong>\u00a0candies between two sisters in such a way that:<\/p>\n\n\n\n\nAlice will get a (a>0)<\/em><\/strong> candies;<\/li>\n\n\n\nBetty will get b (b>0)<\/em><\/strong> candies;<\/li>\n\n\n\neach sister will get some integer<\/strong> number of candies;<\/li>\n\n\n\nAlice will get a greater amount of candies than Betty (i.e. a>b);<\/li>\n\n\n\n all the candies will be given to one of two sisters (i.e. a+b=n).<\/li>\n<\/ul>\n\n\n\nYour task is to calculate the number of ways to distribute exactly n<\/em><\/strong> candies between sisters in a way described above. Candies are indistinguishable.<\/p>\n\n\n\nFormally, find the number of ways to represent n as the sum of n=a+b<\/em><\/strong>, where a and b are positive integers and a>b<\/em><\/strong>.<\/p>\n\n\n\nYou have to answer\u00a0t\u00a0<\/em><\/strong>independent test cases.<\/p>\n\n\n\n<\/div>\n\n\n\n
\u4e2d\u6587\u7ffb\u8b6f<\/strong><\/p>\n\n\n\n\u6709\u5169\u500b\u59ca\u59b9 Alice \u8ddf Betty\uff0c\u73fe\u5728\u4f60\u6709 n<\/em><\/strong> \u500b\u7cd6\u679c\uff0c\u4f60\u5e0c\u671b\u5c07\u9019 n<\/em><\/strong> \u500b\u7cd6\u679c\u6309\u7167\u4ee5\u4e0b\u65b9\u5f0f\u5206\u7d66\u5169\u59ca\u59b9:<\/p>\n\n\n\n\nAlice \u6703\u5f97\u5230 \u00a0a (a>0)<\/em><\/strong> \u9846\u7cd6\u679c<\/li>\n\n\n\nBetty \u6703\u5f97\u5230 \u00a0b (b>0)<\/em><\/strong> \u9846\u7cd6\u679c<\/li>\n\n\n\n\u59ca\u59b9\u90fd\u6703\u5f97\u5230\u67d0\u500b\u6574\u6578<\/strong>\u9846\u7cd6\u679c<\/li>\n\n\n\nAlice \u6703\u6bd4Betty\u5f97\u5230\u66f4\u591a\u7cd6\u679c (a>b)<\/li>\n\n\n\n \u6240\u6709\u7684\u7cd6\u679c\u90fd\u6703\u88ab\u7d66\u4e88\u5176\u4e2d\u4e00\u500b\u4eba (a+b=n)<\/li>\n<\/ul>\n\n\n\n\u4f60\u7684\u4efb\u52d9\u662f\u8981\u8a08\u7b97\u6709\u591a\u5c11\u7a2e\u65b9\u5f0f\u4f86\u5206\u914d n<\/em><\/strong> \u9846\u7cd6\u679c\u7d66\u9019\u5c0d\u59ca\u59b9(\u4f9d\u7167\u4e0a\u9762\u7684\u898f\u5247)<\/p>\n\n\n\n\u5177\u9ad4\u5730\u8aaa\uff0c\u627e\u5230\u5c07 n \u8868\u793a\u70ba n=a+b \u7684\u65b9\u6cd5\u6578\uff0c\u5176\u4e2d a \u548c b \u662f\u6b63\u6574\u6578\uff0c\u4e14 a>b\u3002<\/p>\n\n\n\n
\u4f60\u9700\u8981\u56de\u7b54 t \u500b\u7368\u7acb\u7684\u6e2c\u8a66\u6848\u4f8b\u3002<\/p>\n\n\n\n
<\/div>\n\n\n\n
\u8f38\u5165<\/strong><\/p>\n\n\n\nThe first line of the input contains one integer t (1\u2264t\u2264104<\/sup>) <\/em><\/strong>\u2014 the number of test cases. Then t<\/em><\/strong> test cases follow.<\/p>\n\n\n\nThe only line of a test case contains one integer n (1\u2264n\u22642\u22c5109<\/sup>) <\/em><\/strong>\u2014 the number of candies you have.<\/p>\n\n\n\n\u7b2c\u4e00\u884c\u8f38\u5165\u5305\u542b\u4e86\u4e00\u500b\u6574\u6578 t (1\u2264t\u2264104<\/sup>) <\/em><\/strong>\u2014 \u6e2c\u8a66\u6848\u4f8b\u7684\u6578\u91cf\uff0c\u63a5\u4e0b\u53bb\u6709 t \u500b\u6848\u4f8b\u3002<\/p>\n\n\n\n\u6848\u4f8b\u4e00\u884c\u4e2d\u5305\u542b\u4e86\u4e00\u500b\u6574\u6578 n (1\u2264n\u22642\u22c5109<\/sup>)<\/em><\/strong> \u2014 \u4f60\/\u59b3\u6709\u7684\u7cd6\u679c\u6578\u91cf\u3002<\/p>\n\n\n\n<\/div>\n\n\n\n
\u8f38\u51fa<\/strong><\/p>\n\n\n\nFor each test case, print the answer \u2014 the number of ways to distribute exactly\u00a0n<\/em><\/strong>\u00a0candies between two sisters in a way described in the problem statement. If there is no way to satisfy all the conditions, print\u00a00<\/strong>.<\/p>\n\n\n\n\u5c0d\u6bcf\u4e00\u500b\u6e2c\u8a66\u6848\u4f8b\uff0c\u5370\u51fa\u7b54\u6848 \u2014 \u6709\u591a\u5c11\u7a2e\u65b9\u6cd5\u53ef\u4ee5\u4f9d\u7167\u984c\u76ee\u898f\u5247\u4f86\u5206\u914d \u00a0n<\/em><\/strong> \u9846\u7cd6\u679c\u7d66\u5169\u59ca\u59b9\u3002\u8981\u662f\u6c92\u6709\u4efb\u4f55\u65b9\u6cd5\u4f86\u6eff\u8db3\u6240\u6709\u689d\u4ef6\uff0c\u5247\u56de\u50b3 0<\/strong>\u3002<\/p>\n\n\n\n<\/div>\n\n\n\n
\u7bc4\u4f8b<\/strong><\/p>\n\n\n\n\u8f38\u5165<\/td> 6 7 1 2 3 2000000000 763243547<\/td><\/tr> \u8f38\u51fa<\/td> 3 0 0 1 999999999 381621773<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<\/div>\n\n\n\n
\u7b46\u8a18<\/strong><\/p>\n\n\n\nFor the test case of the example, the 3<\/strong> possible ways to distribute candies are:<\/p>\n\n\n\n\u91dd\u5c0d\u7bc4\u4f8b\u4e2d\u7684\u6e2c\u8a66\u6848\u4f8b(1)\uff0c\u6709\u4e09\u500b\u53ef\u80fd\u7684\u65b9\u5f0f\u4f86\u5206\u914d\u7cd6\u679c<\/p>\n\n\n\n
\na=6, b=1;<\/em><\/strong><\/li>\n\n\n\na=5, b=2;<\/em><\/strong><\/li>\n\n\n\na=4, b=3.<\/em><\/strong><\/li>\n<\/ul>\n\n\n\n<\/div>\n\n\n\n
\n\n\n\n
<\/span>\u89e3\u984c\u601d\u8def<\/span><\/h2>\n\n\n\n\u770b\u5b8c\u984c\u76ee\u4e4b\u5f8c\uff0c\u5148\u4f86\u6574\u7406\u4e00\u4e0b\u908f\u8f2f<\/p>\n\n\n\n
\u9996\u5148\u5169\u59ca\u59b9\u90fd\u5fc5\u9808\u81f3\u5c11\u6709\u4e00\u9846\u7cd6\u679c\uff0c\u4e14Alice\u53c8\u5fc5\u9808\u6bd4Betty\u591a\uff0c\u6545\u6700\u5c11\u61c9\u81f3\u5c11\u70ba3\u9846 (\u8981\u662f\u5c0f\u65bc\u7684\u8a71\uff0c\u4e5f\u5c31\u8868\u793a\u6c92\u8fa6\u6cd5\u5206\u914d\u4e86)<\/p>\n\n\n\n
\u6839\u64da\u4ee5\u4e0a\uff0c\u53ef\u4ee5\u5f97\u5230\u7684\u662f\uff0cBetty\u53ef\u7372\u5f97\u7cd6\u679c\u7684\u7bc4\u570d\u4ecb\u65bc 1 \u5230 n\/2 \u4e4b\u9593(\u4e0d\u5305\u542b)<\/p>\n\n\n\n
<\/div>\n\n\n\n
<\/span>C# \u89e3\u6c7a\u65b9\u6848<\/strong><\/span><\/h3>\n\n\n\n\u65b9\u68481<\/strong><\/p>\n\n\n\nint n = int.Parse(Console.ReadLine());\n\nfor(int i=0; i<n; i++){\n int tmp = int.Parse(Console.ReadLine());\n \n if(tmp<3){\n Console.WriteLine(0);\n }\n else{\n Console.WriteLine(tmp%2==0 ? tmp\/2-1 : tmp\/2);\n }\n}<\/code><\/pre><\/div>\n\n\n\n\u8981\u662f\u8f38\u5165\u662f\u5076\u6578\uff0c\u5247\u5fc5\u9808\u518d\u6e1b1 (ex: 400\/2 = 200\uff0c 200-1 \u5c31\u662fBetty\u80fd\u7372\u5f97\u7684\u6700\u591a\u7cd6\u679c\u6578\uff0c\u4e5f\u662f\u5171\u6709\u5e7e\u7a2e\u5206\u914d\u65b9\u6cd5)<\/p>\n\n\n\n
\u8981\u662f\u5947\u6578\u7684\u8a71\u5c31\u4e0d\u7528\u53e6\u5916\u6e1b1\uff0c\u56e0\u70ba\u6574\u6578\u76f8\u9664\u6642\u5df2\u7d93\u7121\u689d\u4ef6\u6368\u53bb\u5c3e\u6578\u4e86<\/p>\n\n\n\n
<\/div>\n\n\n\n
<\/span>Java \u89e3\u6c7a\u65b9\u6848<\/strong><\/span><\/h3>\n\n\n\n\u65b9\u68481<\/strong><\/p>\n\n\n\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n scanner.nextLine();\n\n for (int i = 0; i < n; i++) \n {\n int tmp = scanner.nextInt();\n scanner.nextLine();\n \n if(tmp<3){\n System.out.println(0);\n }\n else{\n System.out.println(tmp%2==0 ? tmp\/2-1 : tmp\/2);\n }\n }\n }\n}<\/code><\/pre><\/div>\n\n\n\n<\/div>\n\n\n\n