CF 256C Furlo and Rublo and Game【博弈论,SG函数】
来源:互联网 发布:天策成男捏脸数据 编辑:程序博客网 时间:2024/06/05 11:44
暴力的求SG函数会超时,正解是先处理出10^6以内的SG值,对于更大的,开根号之后计算出。
小数据观察可以发现sg函数值成段出现,而且增长速度很快,因此可以计算出来每一段的范围,只需打表即可。
Nim游戏:
Nim和:L.Bouton给出了一个定理,状态(X1, X2, ..., Xn)为必败态当且仅当X1 xor X2 xor .... xor Xn = 0,xor是二进制的按位异或操作。
#include <iostream>#include <algorithm>using namespace std;typedef long long ll;ll x, a[] = {3, 15, 81, 6723, 50625, 2562991875LL};int sg[] = {0, 1, 2, 0, 3, 1, 2}, n, ans = 0;int main() { cin >> n; while (n--) { cin >> x; ans ^= sg[lower_bound(a, a+6, x)-a]; } cout << (ans ? "Furlo" : "Rublo") << endl; return 0;}
- CF 256C Furlo and Rublo and Game【博弈论,SG函数】
- codeforces255E Furlo and Rublo and Game SG函数
- ZOJ 3529 A Game Between Alice and Bob(博弈论-sg函数)
- HDU 1848 Fibonacci again and again 博弈论SG函数
- hdu1848 Fibonacci again and again (博弈论sg函数模板)
- HDU 1848Fibonacci again and again(博弈论:sg函数)
- hdu 4111 Alice and Bob 博弈论 sg函数
- HDU 1848 Fibonacci again and again 博弈论-SG函数
- HDU 1729 Stone Game 【博弈论,SG函数】
- CF Bear and Game
- hdu 1848 Fibonacci again and again 博弈论,求出SG函数,,什么问题都没有了
- POJ-1704(Georgia and Bob)——博弈论、SG函数
- POJ-3537(Crosses and Crosses)——博弈论,SG函数
- A New Stone Game(博弈论之SG函数)
- [博弈论]A Game Between Alice and Bob
- SG函数 Alice and Bob
- Alice and Bob (SG函数)
- hdu 1848 Fibonacci again and again sg值 博弈论
- hdu 3543 Roba number
- 文件过滤驱动操作请求、结果
- 二叉树的序遍历
- 精通软件性能测试与LoadRunner最佳实战 连载八
- C++编程常见错误—cannot have cv-qualifier//不能有CV限定,在C++中CV指const和volatile—1、非成员函数不能有CV限定,2、静态成员函数不能有CV限定
- CF 256C Furlo and Rublo and Game【博弈论,SG函数】
- Mysql性能测试 Mysql性能
- C++文件流ofstream,ifstream
- ios-真机调试出错信息
- Oracle RAC的启动和关闭
- 性能测试工具WAS 性能测试
- js的兼容性问题
- 精通软件性能测试与LoadRunner最佳实战 连载七
- iOS开发中的单元测试(二)——让断言活泼起来的匹配引擎