博弈题。。?这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;
}
本文通过一个具体的示例程序介绍了如何将博弈题转化为数论问题进行解决的方法。通过对输入参数n和k的不同取值情况,实现了对游戏结局的预测。代码中使用了条件判断和取余运算来确定输出结果。
1201

被折叠的 条评论
为什么被折叠?



