UVa 11489 (博弈) Integer Game
一个数字能被3整除就等价于这个数的各个数字之和被3整除。
所以一开始的时候先要拿一个能使剩下的数字是3的倍数的数。
然后就一直拿0、3、6、9直到某人不能再拿为止。
#include <cstdio>
#include <cstring> const int maxn = + ;
char s[maxn];
int a[]; int main()
{
//freopen("in.txt", "r", stdin);
int T;
scanf("%d", &T); getchar();
for(int kase = ; kase <= T; kase++)
{
memset(a, , sizeof(a));
int sum = ;
gets(s);
for(int i = ; i < strlen(s); i++)
{
int x = (s[i] - '') % ;
sum += x;
a[x]++;
} sum %= ;
if(a[sum] == ) { printf("Case %d: %c\n", kase, 'T'); continue; }
int turn = a[] + (int)(!(sum == ));
turn %= ;
printf("Case %d: %c\n", kase, turn ? 'S' : 'T');
} return ;
}
代码君
UVa 11489 (博弈) Integer Game的更多相关文章
- UVA 11489 - Integer Game 博弈
看题传送门 题目大意: S和T在玩游戏,S先.给出一数字串,两人轮流取出一个数字,要求每次取完之后剩下的数为3的倍数,或者没有数字留下.如果两个人足够聪明,求胜利的一方. 思路: 我一开始竟然没有输C ...
- UVA 11489 - Integer Game(找规律)
题目链接 #include <cstdio> #include <cstring> #include <string> #include <cmath> ...
- UVa 1609 (博弈) Foul Play
姑且把它归类为一道博弈吧,毕竟这也是在找必胜方案. 十分有意思的一道题目,设计一种方案让你支持的1队获胜. 题目给出了两个很重要的条件: 1队能打败至少一半的队伍 对于1队不能打败的黑队,一定存在一个 ...
- uva 11489
简单博弈 #include <cstdio> #include <cstdlib> #include <cmath> #include <map> #i ...
- UVa 10891 (博弈+DP) Game of Sum
最开始的时候思路就想错了,就不说错误的思路了. 因为这n个数的总和是一定的,所以在取数的时候不是让自己尽可能拿的最多,而是让对方尽量取得最少. 记忆化搜索(时间复杂度O(n3)): d(i, j)表示 ...
- UVa 11489 整数游戏
https://vjudge.net/problem/UVA-11489 题意: 给出一个数字串n,两个人轮流从中取出一个数字,要求每次取完之后剩下的数是3的倍数,不能取数者输. 思路: 要想取掉一个 ...
- Integer Game(UVA11489)3的倍数
K - Integer Game Time Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Pr ...
- Uva 10891 经典博弈区间DP
经典博弈区间DP 题目链接:https://uva.onlinejudge.org/external/108/p10891.pdf 题意: 给定n个数字,A和B可以从这串数字的两端任意选数字,一次只能 ...
- UVA 1558 - Number Game(博弈dp)
UVA 1558 - Number Game 题目链接 题意:20之内的数字,每次能够选一个数字,然后它的倍数,还有其它已选数的倍数组合的数都不能再选,谁先不能选数谁就输了,问赢的方法 思路:利用dp ...
随机推荐
- MySQL中的配置参数interactive_timeout和wait_timeout(可能导致过多sleep进程的两个参数)
1)interactive_timeout:参数含义:服务器关闭交互式连接前等待活动的秒数.交互式客户端定义为在mysql_real_connect()中使用CLIENT_INTERACTIVE选项的 ...
- 关于json的知识整理
一.什么是json JSON:JavaScript 对象表示法(JavaScript Object Notation). JSON 是存储和交换文本信息的语法.类似 XML,但JSON 比 XML 更 ...
- OC 加密
//MD5加密的结果为128位的二进制数. //所以有128 / 8 = 16字节(8位一个字节). //每八位表示两个16进制数. //MD5 有32个16进制数. //语言层次的所有摘要算法步骤类 ...
- OpenLayers中的Layer概念和实践--Openlayers调用WMS服务
整理转自:http://hi.baidu.com/lixuweiok/item/c406a4e6a6d390e7fa42ba4b 本章我认为是这本书的真正开端,终于开始讲一些有意思的东西了.. 在这一 ...
- arcgis for server 登陆manager失败解决办法
版本是 arcgis for server 10.02 症状 1. manager网页无法打开http://localhost:6080/arcgis/manager/ 2. 查看服务无法启动,启动后 ...
- C# XML - XmlDocument
http://msdn.microsoft.com/zh-cn/library/System.Xml.XmlDocument(v=vs.80).aspx 1.member http://msdn.mi ...
- Codeforces Round #327 (Div. 2) E. Three States
题目链接: 题目 E. Three States time limit per test:5 seconds memory limit per test:512 megabytes 问题描述 The ...
- VisionTimer BUG && Start
void Start() { vp_Timer.In(0.0f, delegate() { Debug.Log("Start"); }, 10, 1.0f); } Version ...
- NData BUG 记录
一.collection 如果设计如下页面 页面模型如下 using UnityEngine; using System.Collections; using System.Collections.G ...
- NET权限系统开源项目
http://www.cnblogs.com/yubaolee/p/OpenAuth.html http://www.cnblogs.com/guozili/p/3496265.html Sereni ...