A Hard Allocation

A Hard Allocation

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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值