uva11489 - Integer Game(考思维,找规律)
从S开始时只能是两种情况:
1.现在总和已经是3的倍数了,那么因为每人每次只能拿走一个数,要保持拿走之后依然是3的倍数,那么就只能拿3,6,9这类数,用num统计一下,看看num奇偶性就知道谁最后拿了。
2.现在总和不是3的倍数,那么要么除3余1要么除3余2,就用num1和num2分别统计两种单个数的数目,看S第一下能不能拿完以后变成3的倍数,能就是按第一种情况分析了,不能T就赢了。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<cctype>
#include<sstream>
using namespace std;
#define pii pair<int,int>
#define LL long long int
const double eps=1e-;
const int INF=;
const int maxn=+;
int T,num,num1,num2,sum;
string s;
int main()
{
//freopen("in1.txt","r",stdin);
//freopen("out.txt","w",stdout);
cin>>T;
int cas=;
while(T--)
{
cin>>s;
sum=num=;
num1=num2=;
int l=s.length();
for(int i=; i<l; i++)
{
int k=s[i]-'';
sum+=k;
if(k%==)
{
num++;
}
else if(k%==)
{
num1++;
}
else num2++;
}
if(sum%==)
{
if(num%==) printf("Case %d: T\n",cas++);
else printf("Case %d: S\n",cas++);
}
else if(sum%==)
{
if(num1>)
{
if(num%==) printf("Case %d: S\n",cas++);
else printf("Case %d: T\n",cas++);
}
else
{
printf("Case %d: T\n",cas++);
}
}
else
{
if(num2>)
{
if(num%==) printf("Case %d: S\n",cas++);
else printf("Case %d: T\n",cas++);
}
else
{
printf("Case %d: T\n",cas++);
}
}
}
//fclose(stdin);
//fclose(stdout);
return ;
}
uva11489 - Integer Game(考思维,找规律)的更多相关文章
- Codeforces D. Little Elephant and Interval(思维找规律数位dp)
题目描述: Little Elephant and Interval time limit per test 2 seconds memory limit per test 256 megabytes ...
- The Bits (思维+找规律)
Description Rudolf is on his way to the castle. Before getting into the castle, the security staff a ...
- [CodeForces - 848B] Rooter's Song 思维 找规律
大致题意: 有一个W*H的长方形,有n个人,分别站在X轴或Y轴,并沿直线向对面走,第i个人在ti的时刻出发,如果第i个人与第j个人相撞了 那么则交换两个人的运动方向,直到走到长方形边界停止,问最后每个 ...
- codeforces Round #440 B Maximum of Maximums of Minimums【思维/找规律】
B. Maximum of Maximums of Minimums time limit per test 1 second memory limit per test 256 megabytes ...
- 1536 不一样的猜数游戏 dp思维 + 找规律
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1536 首先,要知道值为n的答案,则可以这么去想,知道值为n - 1的答案 ...
- Just Random HDU - 4790 思维题(打表找规律)分段求解
Coach Pang and Uncle Yang both love numbers. Every morning they play a game with number together. In ...
- 牛客国庆集训day6 B Board (模拟标记思维或找规律或分块???)
链接:https://www.nowcoder.com/acm/contest/206/B来源:牛客网 题目描述 恬恬有一个nx n的数组.她在用这个数组玩游戏: 开始时,数组中每一个元素都是0. 恬 ...
- 【春训团队赛第四场】补题 | MST上倍增 | LCA | DAG上最长路 | 思维 | 素数筛 | 找规律 | 计几 | 背包 | 并查集
春训团队赛第四场 ID A B C D E F G H I J K L M AC O O O O O O O O O 补题 ? ? O O 传送门 题目链接(CF Gym102021) 题解链接(pd ...
- hdu4952 Number Transformation (找规律)
2014多校 第八题 1008 2014 Multi-University Training Contest 8 4952 Number Transformation Number Transform ...
随机推荐
- VIMTUTOR 1.7中文版
文章来源:http://waterxfire.blog.hexun.com/4106986_d.html =============================================== ...
- spring boot 以jar的方式启动常用shell脚本
用spring boot框架做的项目,将第三方包全部打在jar里面,通过shell脚本启动和停止服务,常用的shell脚本模板如下: #!/bin/bashJAVA_OPTIONS_INITIAL=- ...
- Web安全相关资料
Asp.net安全架构: http://www.cnblogs.com/luminji/category/381486.html
- 20160422 --Switch…case 总结; 递归算法
13 2016-04-22 11:01:00 Switch…case 总结(网摘) 例题: Console.WriteLine("1.汉堡包"); Console.WriteLi ...
- list列表、tuple元组、range常用方法总结
list 列表(数组),是可迭代对象,列表是可变的所以列表的方法都是在列表本身更改的.里面看可以放各种数据类型的数据,可存储大量数据 连接列表可以使用 + 或 extend() a = [1, 3, ...
- 静态库引入引起的错误解决方案,ld: warning: ignoring file ”…/XXX.a”, file was built for archive which is not the architecture being linked (armv7): “…/XXX.a” Undefined symbols for architecture armv7: "_OBJC_CLASS_$
想目中不免会引入一些静态库,可是有时加入'.a'文件后编译便会报以下错误 ld: warning: ignoring file ”…/XXX.a”, file was built for archiv ...
- VC引用静态库
对于路径的设置: Tools->Options->Directory中设置的Lib路径,是给VC环境设置的, 所以只要是这个VC打开的项目,都会包含这些路径. Project->Se ...
- Js 类型方面的神坑
你有没有遇见过本来好好的一个数组结果 typeof 出来是个 object 的情况,你有没有遇到过非要写个 typeof x === "undefined" 判断未赋值的情况... ...
- 前段时间说了AssetBundle打包,先设置AssetLabels,再执行打包,但是这样有个弊端就是所有设置了AssetLabels的资源都会打包,这次说说不设置AssetLabels,该如何打包AssetBundle
BuildPipeline.BuildAssetBundles() 这个函数,有多个重载,一个不用AssetBundleBuild数组,一个需要,如果设置了AssetLabels,那么这时候是不需要的 ...
- 一键安装 lnmp/lamp/lanmp
1.使用putty或类似的SSH工具登陆VPS或服务器 # screen -S lnmp 如果提示screen: command not found 命令不存在可以执行:yum install scr ...