Acm is a clever boy, and he developed a new game form the old Stone-Forfex-Cloth game.

In this game, a number of children sit in a circle, each one
shows a gesture (one of the Stone, the Forfex and the Cloth), which
can't be changed in the whole game. Then a randomly chosen child (we
call him player A) compares his gesture with the one on his
anticlockwise (we call him play B) direction. And the loser should jump
out of the circle. This operation continues until there is only one
child left, which is the winner. Of course the winner is decided by both
the gestures the children show and the order to compare. Your task is
to tell the total number of possible winners.

The game obeys the following rulers:

1. Forfex beat Cloth.

2. Cloth beat Stone.

3. Stone beat Forfex.

4. If it is a draw, play A wins.

Input

The input contains several test cases. In each case, the first
line contains an integer N (the number of children, 1 <= N <=
1000), and the second line contains N capitals including 'S', 'F' and
'C, which are separated by a single space and represent the gestures of N
children in clockwise order. Here 'S' expresses the Stone, 'F'
expresses the Forfex, and 'C' expresses the Cloth.

Output

For each case, output the total number of possible winners in a single line.

Sample Input

3
C S F
2
S C
4
S S S S

Sample Output

3
1
4

poj-2232;Caution_X;20191002;规律;-
description modelling:n个人围成一圈玩石头剪刀布,任选一人开始,逆时再任选一人玩石头剪刀布,输的人出圈,问最后留下的人有多少种情况;-
major steps to solve it:;-
考虑三种情况:;-
(1)所有人只出一个手势,那么任意一个人都有可能留下,答案为n;-
(2)所有人只出两种手势,虽然对手是任意挑选的,但是赢的人的手势是确定的,所以留下的人只能是出了能赢手势的人,此时答案为出了赢得手势的人的人数;-
(3)三种手势都有,显然任意一种手势,只要合理安排对手就一定能赢,所以此时答案还是n;-
warnings:A挑了B当对手,两人出相同手势,A赢;.

AC CODE:

#include<iostream>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
char a[];
set<char> book;
map<char,int> list;
int main()
{
//freopen("input.txt","r",stdin);
int n;
while(~scanf("%d",&n)){
int cnt=;
for(int i=;i<n;i++){
cin>>a[i];
list[a[i]]++;
book.insert(a[i]);
}
if(book.size()==||book.size()==) printf("%d\n",n);
else if(book.size()==) {
if(list['C']!=&&list['S']!=) printf("%d\n",list['C']);
else if(list['F']!=&&list['S']!=) printf("%d\n",list['S']);
else if(list['C']!=&&list['F']!=) printf("%d\n",list['F']);
}
list.clear();
book.clear();
}
return ;
}

poj-2232 New Stone-Forfex-Cloth Game 思维题的更多相关文章

  1. UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There Was One / POJ 3517 And Then There Was One / Aizu 1275 And Then There Was One (动态规划,思维题)

    UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There W ...

  2. [NOIP2005] 过河【Dp,思维题,缩点】

    Online Judge:Luogu P1052 Label:Dp,思维题,缩点,数学 题目描述 在河上有一座独木桥,一只青蛙想沿着独木桥从河的一侧跳到另一侧.在桥上有一些石子,青蛙很讨厌踩在这些石子 ...

  3. zoj 3778 Talented Chef(思维题)

    题目 题意:一个人可以在一分钟同时进行m道菜的一个步骤,共有n道菜,每道菜各有xi个步骤,求做完的最短时间. 思路:一道很水的思维题, 根本不需要去 考虑模拟过程 以及先做那道菜(比赛的时候就是这么考 ...

  4. cf A. Inna and Pink Pony(思维题)

    题目:http://codeforces.com/contest/374/problem/A 题意:求到达边界的最小步数.. 刚开始以为是 bfs,不过数据10^6太大了,肯定不是... 一个思维题, ...

  5. ZOJ 3829 贪心 思维题

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829 现场做这道题的时候,感觉是思维题.自己智商不够.不敢搞,想着队友智商 ...

  6. 洛谷P4643 [国家集训队]阿狸和桃子的游戏(思维题+贪心)

    思维题,好题 把每条边的边权平分到这条边的两个顶点上,之后就是个sb贪心了 正确性证明: 如果一条边的两个顶点被一个人选了,一整条边的贡献就凑齐了 如果分别被两个人选了,一作差就抵消了,相当于谁都没有 ...

  7. C. Nice Garland Codeforces Round #535 (Div. 3) 思维题

    C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  8. PJ考试可能会用到的数学思维题选讲-自学教程-自学笔记

    PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数 ...

  9. HDU 1029 Ignatius and the Princess IV / HYSBZ(BZOJ) 2456 mode(思维题,~~排序?~~)

    HDU 1029 Ignatius and the Princess IV (思维题,排序?) Description "OK, you are not too bad, em... But ...

  10. cf796c 树形,思维题

    一开始以为是个树形dp,特地去学了..结果是个思维题 /* 树结构,设最大点权值为Max,则答案必在在区间[Max,Max+2] 证明ans <= Max+2 任取一个点作为根节点,那么去掉这个 ...

随机推荐

  1. HTML 全局属性(摘自菜鸟教程)

    HTML 全局属性 New : HTML5 新属性. 属性 描述 accesskey 设置访问元素的键盘快捷键. class 规定元素的类名(classname) contenteditableNew ...

  2. FZU - 2150-Fire Game BFS-枚举

    Fire Game 题意: 两个小朋友可以任选一块草地点火,草地可以不同,也可以相同,问最少的烧光草地的时间. 思路: 一开始看到这个以为是联通块计数,没想到这道题通过枚举两个起始点作为队列的初始点, ...

  3. light 1205 - Palindromic Numbers(数位dp)

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1205 题解:这题作为一个数位dp,是需要咚咚脑子想想的.这个数位dp方程可能不 ...

  4. POJ1833 排列 调用全排列函数 用copy函数节省时间 即使用了ios同步代码scanf还是比较快

    排列 Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21268   Accepted: 8049 Description 题 ...

  5. x86_64 Linux 运行时栈的字节对齐

    前言 C语言的过程调用机制(即函数之间的调用)的一个关键特性(起始大多数编程语言也是如此)都是使用了栈数据结构提供的后进先出的内存管理原则.每一个函数的栈空间被称为栈帧,一个栈帧上包含了保存的寄存器. ...

  6. hotcss.js Flexible 移动端适配在dpr=2和dpr=3出现的字体大小设置不正确问题.

    这段时间一直在用hotcss做移动端适配,做了几个页面没有发现什么问题,后来老大要加快进度,我把项目分出一块给另一个同事做,她发现了一个问题就是字体在dpr=2,dpr=3,的设备上字体大小显示老是不 ...

  7. Redis字符串键的底层原理

    before C语言基础 Redis基础 导入 redis的命令如下: set x "hello"; get x; hello Redis作为一种存储字符串的缓存结构,其具体实现是 ...

  8. RedisTemplate.opsForValue 常用方法

    RedisTemplate.opsForValue 常用方法 1.set(K key, V value) 新增一个字符串类型的值,key是键,value是值. redisTemplate.opsFor ...

  9. lambda表达式排序

    lambda表达式排序简洁 1.给一个字符串数组: String[] atp = {"2016-06-28 08:00:00", "2017-12-05 19:17:32 ...

  10. elk安装和使用

    elk安装和使用 使用的版本都是5.2.0 elasticsearch-5.2.0安装 在官网 下载 elasticsearch tar包 解压安装 tar zxf elasticsearch-5.2 ...