典型的尼姆博弈,在n对石子中,告诉你每堆的数目和每次从该堆最多可以取的数目,求最终谁将其取完。
题解:SG(i)=mi%(li+1),求异或值即可。
1
2
3
4
5
6
7
8
9
10
11
12
13 |
#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; } |
HDU 1851 A Simple Game,布布扣,bubuko.com
原文:http://www.cnblogs.com/forever97/p/3676540.html