参考:https://blog.csdn.net/Izumi_Hanako/article/details/80189596
胜负和操作次数有关,先手胜为奇,所以先手期望奇数后手期望偶数,最后一定能达到m,m,m,...n%m的操作次数最大局面
然后看达到这个状态的操作数的奇偶性即可

#include<iostream>
#include<cstdio>
using namespace std;
int t,n,m,a,b,ans;
int main()
{
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&m);
        a=(n-1)%m%2,b=(n-1)/m%2;
        ans=a^1;
        if(m%2==0)
			ans^=b;
        printf("%d\n",ans);
    }
    return 0;
}

相关文章:

  • 2021-07-13
  • 2021-07-04
  • 2022-12-23
  • 2021-07-24
  • 2021-10-26
  • 2022-12-23
  • 2022-03-02
  • 2022-12-23
猜你喜欢
  • 2021-10-28
  • 2021-06-14
  • 2021-06-03
  • 2022-03-08
  • 2022-12-23
  • 2021-11-11
  • 2022-02-14
相关资源
相似解决方案