LA5059 Playing With Stones
2017-03-31 11:16
267 查看
题意:nim游戏。加上限制每次不得取走超过当前堆一半的石子
1 ≤ N ≤ 100,1 ≤ ai ≤ 2 ∗ 1018[b]分析:由于ai过大。所以我们采用SG函数递推找规律。[/b]
[b](详见代码)[/b]
#include<cstdio> using namespace std; typedef long long ll; int T,n;ll x,S; ll GetSG(ll x){ return x&1?GetSG(x>>1):x>>1; } int main(){ for(scanf("%d",&T);T--;){ for(scanf("%d",&n),S=0;n--;){ scanf("%lld",&x); S^=GetSG(x); } if(S) puts("YES"); else puts("NO"); } return 0; }
相关文章推荐
- LA5059 Playing With Stones
- LA5059 Playing With Stones
- UVALive 5059 C - Playing With Stones 博弈论Sg函数
- UVaLive5059 Playing With Stones
- LA 5059 - Playing With Stones
- La 5059 - Playing With Stones
- UESTC 1661 Playing With Stones 博弈打表
- 【LA 5059】 Playing With Stones|博弈论|SG函数
- UVA1482:Playing With Stones(SG)
- UVA - 1482 Playing With Stones
- Nim游戏的一个扩展——51nod 1661 黑板上的游戏+LA 5059 Playing With Stones
- uva 1482 - Playing With Stones
- LA 5059 (找规律 SG函数) Playing With Stones
- UVALive 5059 C Playing With Stones
- sgu 153 Playing with matches
- A. Playing with Paper
- CS 20SI|Lecture 7 Playing with convolutions in TensorFlow
- Playing with cubes II
- Playing with ptrace, Part I
- A. Playing with Paper