uva 1482 - Playing With Stones
2013-11-01 23:17
453 查看
对于组合游戏的题;
首先把问题建模成NIM等经典的组合游戏模型;
然后打表找出,或者推出SG函数值;
最后再利用SG定理判断是否必胜必败状态;
View Code
首先把问题建模成NIM等经典的组合游戏模型;
然后打表找出,或者推出SG函数值;
最后再利用SG定理判断是否必胜必败状态;
#include<cstdio> #define ll long long using namespace std; ll sg(ll x) { return x%2==0 ? x/2 : sg(x/2); } int main() { int t; scanf("%d",&t); while(t--) { int n; ll a,ans=0; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%lld",&a); ans^=sg(a); } puts(ans==0?"NO":"YES"); } return 0; }
View Code
相关文章推荐
- UVA - 1482 Playing With Stones
- UVA1482:Playing With Stones(SG)
- UVALive 5059 C Playing With Stones
- UVALive 5059 C - Playing With Stones 博弈论Sg函数
- UVaLive5059 Playing With Stones
- UVALive 6555 Playing Fair with Cryptography(细节处理)
- UVA 1482 - Playing With Stones(SG打表规律)
- UVa Problem 10067 Playing With Wheels (摆弄轮子)
- Nim游戏的一个扩展——51nod 1661 黑板上的游戏+LA 5059 Playing With Stones
- uva10067 Playing with Wheels 【建图+最短路】
- La 5059 - Playing With Stones
- PC/UVa 110902/10067 Playing With Wheels
- LA 5059 (找规律 SG函数) Playing With Stones
- UVa 10067 - Playing with Wheels
- LA5059 Playing With Stones
- LA 5059 - Playing With Stones
- UESTC 1661 Playing With Stones 博弈打表
- UVA 1482 - Playing With Stones (SG博弈)
- LA5059 Playing With Stones
- [uva] 10067 - Playing with Wheels