|
||||||||||
A Hard AllocationTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2429 Accepted Submission(s): 1148 Problem Description One day, WNJXYK came out an excellent idea that he could give his friends his special cakes which made of kiwis to eat in parties. But the process of making this kind of special cakes is very complex. One day, his friend Kayaking gave him a formulation which allows WNJXYK to produce one special cake with exact one kiwi in no time. Now let us have a big party over anyone’s imagination. To simply this question we can assume that WNJXYK invited m friends to his house and he only had n kiwis this time. He wanted to produce special cakes with Kayaking’s formulation and give them to his friends. Usually, it maybe not possible for people to get exactly same number of cakes in some situations. We can assume that people who received the most one get x cakes and people who received the least get y cakes. WNJXYK wondered that what is the minimal value of |x-y|? Input The input starts with one line contains exactly one positive integer T which is the number of test cases. Each test case contains one line with exactly two positive integer n,m which has been explained above. Output For each test case, output one line containing “y” where y is the number of minimal difference. Sample Input
Sample Output
Hint 1<=T<=100,1<=n,m<=1000 Source | ||||||||||
|