UVA 1482 - Playing With Stones(SG打表规律)
2017-05-02 09:01
302 查看
UVA 1482 - Playing With Stones
题目链接题意:给定n堆石头,每次选一堆取至少一个。不超过一半的石子,最后不能取的输,问是否先手必胜
思路:数值非常大。无法直接递推sg函数。打出前30项的sg函数找规律
代码:
#include <stdio.h> #include <string.h> int t, n; long long num; long long SG(long long x) { return x % 2 == 0 ? x : SG(x / 2); } int main() { scanf("%d", &t); while (t--) { scanf("%d", &n); long long ans = 0; for (int i = 0; i < n; i++) { scanf("%lld", &num); ans ^= SG(num); } printf("%s\n", ans == 0 ? "NO" : "YES"); } return 0; }
相关文章推荐
- UVA 1482 - Playing With Stones(SG打表规律)
- UVA 1482 - Playing With Stones (SG博弈)
- UVA-1482 Playing With Stones(SG函数打表找规律)
- UVA1482:Playing With Stones(SG)
- uva 1482 - Playing With Stones(Nim游戏)
- 尼姆博奕HDU 5795 A Simple Nim(SG打表找规律)
- UVALive 6844 Combination(打表找规律)
- HDU 3032 Nim or not Nim? SG打表找规律
- uva 12716 打表找规律
- UVA 10706 Number Sequence (找规律 + 打表 + 查找)
- HDU 3032 Nim or not Nim?(博弈 SG打表找规律)
- UVALive 5116 Dividing Stones(dfs + 打表)
- UVa11582 - Colossal Fibonacci Numbersl (打表找规律)
- hdu 2147 kiki's game(DP(SG)打表找规律)
- HDU 3032 Nim or not Nim?(Multi_SG,打表找规律)
- HDU 5795 A Simple Nim(SG打表找规律)——2016 Multi-University Training Contest 6
- hdu3032 Nim or not Nim? SG打表找规律
- UVA - 1482 Playing With Stones
- uva 10515 规律打表
- hdu4203 Doubloon Game-------sg 打表找规律