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 ...
随机推荐
- 剑指offer 面试15题
面试15题: 题目:二进制中1的个数 题:输入一个整数,输出该数二进制表示中1的个数.其中负数用补码表示. 解题思路一: 最佳方法:把一个整数减去1,再和原整数做“与运算”,会把该整数最右边的1变成0 ...
- settings配置 文件操作
设置文件路径 import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) 这里用到了python中一个神奇的变量 __file__ ...
- rails generator
generate 查找顺序 rails/generators/initializer/initializer_generator.rb generators/initializer/initializ ...
- Kattis - pseudoprime 【快速幂】
题意 给出两个数字 P 和 A 当p 不是素数 并且 满足a^p≡a(mod p) 就输出 yes 否则 输出 no 思路 因为 数据范围较大,用快速幂 AC代码 #include <cstdi ...
- iOS UIFont 的学习与使用
通常,我们使用字体 都是系统默认的字体. 有时候 从阅读体验,美观度 设计师都会考虑用一些 更高大尚的字体. 系统字体库 给英文 各种style的发挥空间很大,但是 中文则不然. 但是苹果 给使用中文 ...
- Apache commons-io实现多文件读取和写入
需求: "E:/data/"目录下有四个文件夹,如下: 每个文件夹下有几个.csv文件,如下: 将每个文件夹下的.csv文件合并成一个以该文件夹命名的.csv文件. 做法: 找到& ...
- 验证——正则<37>
1,郵箱合法性驗證 /* * 郵箱合法性驗證 * @method matchTel * @papram{string} str,電子郵箱 * @return{boolean} * */ functio ...
- volatile笔记
总结自:https://www.cnblogs.com/dolphin0520/p/3920373.html 了解volatile之前得明白什么是原子性.可见性.有序性及指令重排序,详见:https: ...
- JavaWeb CSS
1. CSS介绍 1.1. 什么是CSS CSS全称为Cascading Style Sheets,译为层叠样式表. 样式定义如何显示HTML元素. 样式通常存储在样式表中. 1.2. 百度百科 CS ...
- [RK3288][Android6.0] TS-ADC驱动流程小结【转】
本文转载自:https://blog.csdn.net/kris_fei/article/details/55045936 Platform: RK3288OS: Android 6.0Kernel: ...