简单博弈

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <sstream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iostream>
#define maxn 1010
#define INF 0x7fffffff
#define inf 10000000
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
using namespace std; char s[maxn];
int num[10], sum, len; void init()
{
memset(num, 0, sizeof(num));
sum = 0;
len = strlen(s);
for(int i = 0; i < len; ++ i)
{
num[s[i]-'0'] ++;
sum += s[i] - '0';
}
} bool judge()
{
int ans = num[0]+num[3]+num[9]+num[6];
return ans%2;
} int main()
{
int t, ca = 1;
scanf("%d", &t);
getchar();
while(t--)
{
gets(s);
init();
printf("Case %d: ", ca++);
if(sum%3 == 0)
{
if(judge()) puts("S");
else puts("T");
}
else
{
int i;
for(i = 1; i < 10; ++ i)
if(num[i] && (sum-i)%3 == 0)
{
num[i] --;
break;
}
if(i < 10 && !judge()) puts("S");
else puts("T");
}
}
return 0;
}

uva 11489的更多相关文章

  1. UVA 11489 - Integer Game(找规律)

    题目链接 #include <cstdio> #include <cstring> #include <string> #include <cmath> ...

  2. UVa 11489 (博弈) Integer Game

    一个数字能被3整除就等价于这个数的各个数字之和被3整除. 所以一开始的时候先要拿一个能使剩下的数字是3的倍数的数. 然后就一直拿0.3.6.9直到某人不能再拿为止. #include <cstd ...

  3. UVa 11489 整数游戏

    https://vjudge.net/problem/UVA-11489 题意: 给出一个数字串n,两个人轮流从中取出一个数字,要求每次取完之后剩下的数是3的倍数,不能取数者输. 思路: 要想取掉一个 ...

  4. UVA 11489 - Integer Game 博弈

    看题传送门 题目大意: S和T在玩游戏,S先.给出一数字串,两人轮流取出一个数字,要求每次取完之后剩下的数为3的倍数,或者没有数字留下.如果两个人足够聪明,求胜利的一方. 思路: 我一开始竟然没有输C ...

  5. Integer Game(UVA11489)3的倍数

    K - Integer Game Time Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Pr ...

  6. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  7. UVA 10564 Paths through the Hourglass[DP 打印]

    UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...

  8. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

  9. UVA&&POJ离散概率与数学期望入门练习[4]

    POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...

随机推荐

  1. apache commons-email1.3使用

    apache commons-email1.3下载地址:   https://repository.apache.org/content/repositories/orgapachecommons-0 ...

  2. SequoiaDB数据库集群部署

    一般在多机环境下部署数据库的集群模式是比较繁琐的,下面我来分享一个如何通过shell脚本的方式简单.方便地部署我们的集群. 首先,我们要给机器配置信任关系,这样我们就无需手动的输入密码来执行ssh和s ...

  3. WordPress 主题开发 - (一) 前言 待翻译

    原文出自: http://themeshaper.com/2012/10/22/the-themeshaper-wordpress-theme-tutorial-2nd-edition/ THE TH ...

  4. pyQuery

    pyquery – PyQuery complete API 选择器基本支持jQuery用法 class pyquery.pyquery.PyQuery(*args, **kwargs) The ma ...

  5. Python计算斗牛游戏的概率

    Python计算斗牛游戏的概率 过年回家,都会约上亲朋好友聚聚会,会上经常会打麻将,斗地主,斗牛.在这些游戏中,斗牛是最受欢迎的,因为可以很多人一起玩,而且没有技术含量,都是看运气(专业术语是概率). ...

  6. Mac OS X 10.10.2 Yosemite jdk 环境变量配置

    我的Mac系统版本是OS X 10.10.2 Yosemite,为了用Eclipse做android开发,安装了jdk 1.7, 但是如果想使用IntelliJ IDE做android开发的话,就需要 ...

  7. iOS内存管理retain,assign,copy,strong,weak

    转自:http://www.cnblogs.com/nonato/archive/2013/11/28/3447162.html iOS的对象都继承于NSObject, 该对象有一个方法:retain ...

  8. class_create(),device_create()使用

    开始写Linux设备驱动程序的时候,很多时候都是利用mknod命令手动创建设备节点(包括ldd3中不少例子也是这样),实际上现在Linux内核为我们提供了一组函数,可以用来在模块加载的时候自动在/de ...

  9. 多态&&父类调用子类特有的方法

    /* 多态 1.没有继承就没有多态 2.代码的体现:父类类型的指针指向子类对象 3.好处:如果函数\方法参数使用的是父类对象,可以传入父类.子类对象 4.局限性: 1>父类类型的变量,不能直接调 ...

  10. Quartz.net 的开源任务管理平台

    Quartz.net 的开源任务管理平台 前面总结了很多,关于Quartz.net 的文章,介绍了如何使用Quartz.net.不清楚的朋友,可以看我之前的系列文章,http://www.cnblog ...