[博弈论] cf317 D Game with Powers
来源:互联网 发布:在线看熊片的软件 编辑:程序博客网 时间:2024/05/01 20:12
[博弈论] cf317 D Game with Powers
@(ACM题目)[博弈论]
#include<iostream>#include<cstdio>#include <cstring>#include<cmath>#include<cstdlib>#include<climits>#include<algorithm>#include<vector>#include<map>#include<set>#include<list>#include<stack>using namespace std;typedef long long LL;/*const int maxn = 1e9+1e8;char sg[maxn];int getsg(int S){ if(sg[S] != -1) return sg[S]; bool vis[31] = {0}; for(int i = 1; i <= 30; i++) if(S&(1<<(i-1))) { int tmp = S; for(int j = i; j <= 30; j += i) { if(S&(1<<(j-1))) tmp -= 1<<(j-1); } vis[getsg(tmp)] = 1; } for(int i = 0; i <= 30; i++) if(!vis[i]) return sg[S] = i;}int main(){ memset(sg, -1, sizeof sg); sg[0] = 0; getsg((1<<29)-1); for(int i = 0; i < 30; i++) cout<<(int)sg[(1<<i)-1]<<","; return 0;}*/const int maxn = 1e5;int sg[] = {0,1,2,1,4,3,2,1,5,6,2,1,8,7,5,9,8,7,3,4,7,4,2,1,10,9,3,6,11,12};bool vis[maxn] = {0};int main(){ int n, m; cin>>n; if(n==1) return puts("Vasya"), 0; m = sqrt(n+0.5); int res = sg[1]; int dif = 0; for(int i = 2; i <= m; i++) if(!vis[i]) { int k = 0; for(LL j = i; j <= n; j *= i) { if(j <= m) vis[j] = true; else dif++; k++; } res ^= sg[k]; } if((n-m-dif)&1) res ^= sg[1]; puts(res?"Vasya":"Petya"); return 0;}
0 0
- [博弈论] cf317 D Game with Powers
- CodeForces 317 D.Game with Powers(博弈论)
- CodeForces 317D Game with Powers
- Codeforces Round #188 (Div. 1) D. Game with Powers
- Problem H. Game with the Stones 博弈论
- D - Game with Pearls
- D.Game with Pearls
- 博弈论---Game!
- GYM 100090 H.Game with the Stones(博弈论)
- Codeforces Round #188 (Div. 1) Game with Powers 引发的联想 NIM游戏 Sprague Grundy Theory
- CodeForces 386D Game with Points
- Create 2D game with Unity 3D - ( 1 )
- Game Theory 博弈论
- ZOJ2290 Game,博弈论
- Nim Game (博弈论)
- poj_1082_Calendar Game(博弈论)
- HDU 5011 Game(博弈论)
- hdu1856 Brave Game(博弈论)
- 是否完全二叉搜索树 (30分)
- 爱拼宝宝,电商小程序
- UEFI启动模式下安装Ubuntu 16.04教程
- leet_257. Binary Tree Paths-根到叶子的路径
- 数据结构实验之链表九:双向链表
- [博弈论] cf317 D Game with Powers
- LeetCode 104. Maximum Depth of Binary Tree 题解
- 今天开始陆陆续续写博客,做更优秀的程序员
- maven的安装
- Python EOF 的错误
- 码
- 最熟悉的陌生属性——position
- 欢迎使用CSDN-markdown编辑器
- SCOI2012喵星球的点名--后缀数组