HDU 1851 A Simple Game

典型的尼姆博弈,在n对石子中,告诉你每堆的数目和每次从该堆最多可以取的数目,求最终谁将其取完。

题解:SG(i)=mi%(li+1),求异或值即可。

#include <cstdio>
int main(){
    int T,i,n,SG,m,l;
    scanf("%d",&T);
    while(T--){
        scanf("%d",&n);
        SG=0;
        for(i=1;i<=n;i++)scanf("%d%d",&m,&l),SG=SG^(m%(l+1));
        if(SG==0)puts("Yes");
        else puts("No");
    }    
    return 0;
}    
原文地址:https://www.cnblogs.com/forever97/p/3676540.html