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 ...
随机推荐
- requirejs神奇问题,data-main修改后,刷新没有重新载入
同事在使用require的时候,在配置地方增加 urlArgs: "bust=" + (new Date()).getTime(), 然后问题又来了,这个相当于js版本的东东会把 ...
- Dancing Link专题
一些链接: http://www.cnblogs.com/-sunshine/p/3358922.html http://www.cnblogs.com/grenet/p/3145800.html 1 ...
- Linux下运行java项目
最近初步接触了linux,感觉很有新鲜感.之前在windows下干过的事情也便想到在linux环境下实现一下.正好手头在编java,就想既然java可以在windows的DOS操作下运行,是不是也可以 ...
- 快速查找文件——Everything
Everything Search Engine Locate files and folders by name instantly. Small installation file Clean a ...
- Python编程-架构、Socket
一.客户端/服务器架构 1.C/S架构 Client/Server架构,即服务器/客户端架构. 客户端和服务器端的程序不同,用户的程序主要在客户端,服务器端主要提供数据管理.数据共享.数据及系统维护和 ...
- CoreData的基本操作
Managed Object Model(被管理对象模型): –数据库的轮廓,或者结构.包含了各个实体的定义信息 Persistent Store Coordinator (持久性数据协调 ...
- Jquery 获取地址位置
直接在浏览器地址 输入: http://pv.sohu.com/cityjson?ie=utf-8 可以查看数据格式 引入一个搜狐的js库: <script src="http://p ...
- .NET 中如何判断文件与目录
FileInfo fileInfo = new FileInfo(pth); if ((fileInfo.Attributes & FileAttributes.Directory) != 0 ...
- poj 3126 Bfs
Prime Path Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14539 Accepted: 8196 Descr ...
- rollingstyle in log4net
https://stackoverflow.com/questions/734963/log4net-rollingfileappender-with-composite-rolling-style- ...