UVA-1482 Playing With Stones(SG函数打表找规律)
来源:互联网 发布:对冲基金编程 编辑:程序博客网 时间:2024/04/30 06:55
Playing With Stones UVA1482
今天训练博弈的时候看到了这道题,看到1e18的数据很快就把SG函数表打了出来,准备找规律,但是无论怎么找都找不到一个比较好的公式,后来看了别人的博客,发现只要a是奇数,那么SG(a)=SG(a/2),这个规律实在是高明,让这道题直接变成水题,膜拜大佬。
#pragma comment(linker, "/STACK:1024000000,1024000000") #include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cstdlib>#include <cmath>#include <vector>#include <queue>#include <map>#include <algorithm>#include <set>#include <functional>using namespace std;typedef long long LL;typedef unsigned long long ULL;const int INF = 1e9 + 5;const int MAXN = 1000005;const int MOD = 1e9 + 7;const double eps = 1e-8;const double PI = acos(-1.0);LL getSG(LL x){if (x & 1)return getSG(x / 2);return x / 2;}int main(){int T;int n;LL ans;LL x;scanf("%d", &T);while (T--){ans = 0;scanf("%d", &n);while (n--){scanf("%lld", &x);ans ^= getSG(x);}if (ans == 0)printf("NO\n");elseprintf("YES\n");}}
阅读全文
0 0
- UVA-1482 Playing With Stones(SG函数打表找规律)
- UVA 1482 - Playing With Stones(SG打表规律)
- UVA 1482 - Playing With Stones (SG博弈)
- UVA - 1482 Playing With Stones
- UVA1482:Playing With Stones(SG)
- 【LA 5059】 Playing With Stones|博弈论|SG函数
- uvalive 5059 Playing With Stones(组合游戏,SG函数)@
- uva 1482 - Playing With Stones(Nim游戏)
- LA5059 Playing With Stones
- La 5059 - Playing With Stones
- UVALive 5059 Play with Stones SG函数,难度较低
- hdu_1517(SG函数+打表找规律)
- UVALive 5059 C Playing With Stones
- hdu5795A Simple Nim(SG函数、打表找规律)
- UVa 10067 - Playing with Wheels
- UESTC 1661 Playing With Stones 博弈打表
- UVALive/LA 5059 Play with Stones 组合游戏/SG定理
- PC/UVa 110902/10067 Playing With Wheels
- SQL中的JOIN
- 查找总结
- 类与对象
- .NET预防SQL注入的简易代码
- MQTT 服务器
- UVA-1482 Playing With Stones(SG函数打表找规律)
- linux tcp Linux的SOCKET编程详解
- 双向链表
- Python中operator模块的操作
- 顺序表应用6:有序顺序表查询
- 387. First Unique Character in a String
- javascrpt里的reverse 反转
- dwz table表格自动适应宽度
- 锁的内存语义