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
3
5 5
3 10
6 7
Sample Output
0
1
1
Hint
1<=T<=100,1<=n,m<=1000
思路还是比较简单的 要想最多的人和最少的人分到的差距最小很显然非0即1;
只需要我们判断一下n,m能否整除能就说明能平均分否则不能平均分不能平均分那也肯定是在分那小于m个蛋糕的时候不够的 那一定就是1了简单题。
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main(){
int n,m,k,s,sum;
cin>>n;
getchar();
while(n--)
{
cin>>k>>m;
if(k%m==0)
cout<<0<<endl;
else
cout<<1<<endl;
}
return 0;
}