UVA11489Integer Game
来源:互联网 发布:mac粉底液nc15白不白 编辑:程序博客网 时间:2024/05/07 19:06
题意:从一串数里面选一个,使得剩下的数之和为3的倍数,若没有数可以选则对面赢了。
思路:简单博弈论。如果第一次取能取,那么之后取的都必须是3的倍数。可以从3的倍数的数的个数的奇偶性得出结果。
代码:
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <queue>#include <vector>#define DB puts("**de**")#define WATCH(a) cout << a << endl#define REP(i,n) for(int i=0;i<n;++i)#define FF(i,a,b) for(int i=a;i<=b;++i)#define CL(a,b) memset(a,b,sizeof(a))#define LL long long#define FD(i,a,b) for(int i=a;i>=b;--i)#define pb push_back#define pr pair<int,int >//#pragma comment(linker, "/STACK:1024000000,1024000000")using namespace std;//constconst int MAXN=1e6+5;const int INF=0x3f3f3f3f;//struct//global//vector<int> edge[MAXN];int ti1,ti2,ti3,n,m,t,ncase;double td1,td2,td3;char tc1,tc2;char s[1005];//funcint main(){ //freopen("C:\\Users\\inkysakura\\Desktop\\testdata.txt","r",stdin); cin >> n; for(int i=1;i<=n;i++) { int vis[10],f=1,sum=0,num=0; CL(vis,0); cin >> s; cout << "Case "<<i<<": "; int len=strlen(s); if(len==1) {cout << "S"<<endl;continue;} for(int j=0;j<len;j++) { if((s[j]-'0')%3==0)num++; sum+=s[j]-'0'; vis[s[j]-'0']=1; } for(int j=0;j<10;j++) if(vis[j]&&(sum-j)%3==0) { if(j%3==0) num--; f=0; break; } if(num&1||f) cout <<"T"<<endl; else cout << "S"<<endl; } return 0;}
0 0
- UVA11489Integer Game
- UVA11489Integer Game博弈
- game
- game
- game
- game...
- Game
- Game
- Game
- Game
- game
- Game
- Game
- game
- game
- Game
- GAME
- Game
- 173.leetcode Binary Search Tree Iterator(medium)[二叉搜索树 栈 中序遍历]
- 深入阅读gulp源码小结
- POJ 3420 Quad Tiling DP?递推?+矩阵快速幂
- discuz 可以使用多种缓存
- Linux bash shell中变量的设置和使用
- UVA11489Integer Game
- HDU 1596 find the safest road
- 【Arduino官方教程】数字处理示例(五):按键状态变化检测
- 利用Eclipse集成开发环境进行ROS开发
- 会话管理之Session
- 关于LCA(Tarjan+ST)
- CENTOS 6.5 配置YUM安装NGINX
- 二叉树的建立和基础操作<三> —— (三种遍历及分层打印)
- HTML5地理位置Geolocation以及百度地图应用