hdu 4203

来源:互联网 发布:java中inputstream 编辑:程序博客网 时间:2024/05/09 08:11

博弈题。。?这tm根本就是一道数论题!!f*。。

#include<iostream>#include<vector>using namespace std;int n,k;int main(){    int T;    cin>>T;    while(T--)    {        cin>>n>>k;        if(k%2)        {            if(n%2)            {                cout<<"1"<<endl;            }            else            {                cout<<"0"<<endl;            }        }        else        {            if(n%(k+1)==k)            {                cout<<k<<endl;            }            else if((n%(k+1))%2)            {                cout<<"1"<<endl;            }            else            {                cout<<"0"<<endl;            }        }    }    return 0;}