CodeForces 603C Lieges of Legendre (SG函数)
来源:互联网 发布:lol盲僧怎么玩 知乎 编辑:程序博客网 时间:2024/06/05 17:59
分析:第一次写博弈的题目,虽然这题比较简单。
如果
那么选择
选择
确定状态
接着递归处理就行了,直接多写几个就能发现规律。
如果
那么选择
选择
确定状态
接着递归处理就行了。
复杂度:
附上代码:
#include <bits/stdc++.h>#define LL long long#define FOR(i,x,y) for(int i = x;i < y;++ i)#define IFOR(i,x,y) for(int i = x;i > y;-- i)using namespace std;const int maxn = 100010;int a[maxn],n,k;int odd_sg(int x){ if(x == 0) return 0; if(x == 1) return 1; if(x == 2) return 0; if(x == 3) return 1; if(x % 2) return 0; int t1 = odd_sg(x-1),t2 = odd_sg(x>>1); FOR(i,0,4) if(i != t1 && i != t2) return i;}int main(){ //freopen("test.in","r",stdin); while(~scanf("%d%d",&n,&k)){ FOR(i,0,n) scanf("%d",&a[i]); int ans = 0; FOR(i,0,n){ int res; if(k % 2 == 0){ if(a[i] == 1) res = 1; else if(a[i] == 2) res = 2; else res = 1-(a[i]%2); } else res = odd_sg(a[i]); ans ^= res; } if(ans > 0) printf("Kevin\n"); else printf("Nicky\n"); } return 0;}
0 0
- CodeForces 603C Lieges of Legendre (SG函数)
- codeforces 603C. Lieges of Legendre(博弈+SG函数)
- CodeForces 603C/604E Lieges of Legendre SG函数
- [Codeforces 603C]Lieges of Legendre
- codeforces 604 E. Lieges of Legendre (sg函数)
- codeforces 604 E. Lieges of Legendre (sg函数)
- Codeforces Round #334 E. Lieges of Legendre(SG)
- codeforces #334 div1 603C Lieges of Legendre(博弈)
- Codeforces Round #334 (Div. 2) C. Lieges of Legendre
- Codeforces Round #334 E. Lieges of Legendre (组合游戏)
- 【Codeforces Round 334 (Div 2)E】【博弈-SG函数】Lieges of Legendre n个数 每次取数-1或者变2x为k个x的博弈
- nim博弈 Codeforces603C Lieges of Legendre
- codeforces603CLieges of Legendre+SG博弈
- codeforces 850c sg函数
- Game of Hyper Knights (SG函数)
- LightOJ 1315 - Game of Hyper Knights(博弈sg函数)
- gdfzoj #549 Homework of Politics(SG函数+快速幂)
- codefoeces 603C (博弈 SG函数找规律)
- 最基本的json使用(一)
- 表单
- 覆写
- Linux C 编程技巧--利用有限状态机模型编程
- linux应用编程笔记(15)消息队列编程
- CodeForces 603C Lieges of Legendre (SG函数)
- LeetCode(101) Symmetric Tree解题报告
- Beginning Python Chapter4
- 获取JAVA文件路径
- java从菜鸟到大神的成神之路学习路线_me
- 九度题目1525:子串逆序打印
- 编写和运行简单的Applet程序
- 微信 未读 置顶 删除 的简单实现
- unity3d调用win32打开对话框