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. Azure Devops: COPY failed: stat /var/lib/docker/tmp/docker-builder268095359/xxxxxxx.csproj no such file or directory

    在Azure Devops中部署docker镜像时,  出现COPY failed: stat /var/lib/docker/tmp/docker-builder268095359/xxxxxxx. ...

  2. 导航页的开发--手机web app开发笔记

    好了,的所有的基础知识已经准备完毕了,现在开始制作引导页.这个引导页需要一个HTML文件,JS文件,一个CSS文件.在HBuilderX中根目录下添加“Guid.html”,在JS文件夹添加“myth ...

  3. 谈谈我对SOFA模块化的理解

    今天我们谈谈SOFA模块化,首先看一段SOFA的介绍: SOFABoot是蚂蚁金服开源的基于Spring Boot的研发框架,它在Spring Boot的基础上,提供了诸如 Readiness Che ...

  4. net core WebApi——尝试企业微信内部应用

    目录 前言 企业微信 开始 测试 小结 @ 前言 这几天忙活着别的东西,耽误了很长时间,从文件操作完了之后就在考虑着下一步鼓捣点儿啥,因为最开始的业务开发就是企业微信相关的,这刚好来做个内部应用的小例 ...

  5. HashMap并发下死循环问题解析

    首先小伙伴要明确:死循环问题在JDK 1.8 之前是存在的,JDK 1.8 通过增加loHead和loTail进行了修复. 在JDK 1.7及之前 HashMap在并发情况下导致循环问题,致使服务器c ...

  6. Delphi - 本地路径的创建、清空本地指定文件夹下的文件

    本地路径的创建 在做下载操作时,我们一般先把文件下载到本地指定的路径下,然后再做其他使用. 为了防止程序出现异常,我们通常需要先判断本地是否存在指定的路径. 以C盘Tmp文件夹为例,我们可以这样做,代 ...

  7. 自己实现vue瀑布流组件,含详细注释

    我知道vue有瀑布流插件vue-waterfall-easy,但是使用的时候与我的预期有部分别,所以就自己动手写了这个组件 人和动物的根本区别是是否会使用工具,我们不仅要会使用,还要会创造工具,别人提 ...

  8. 转载 江南一点雨 一键部署docker

    一键部署 Spring Boot 到远程 Docker 容器,就是这么秀!   不知道各位小伙伴在生产环境都是怎么部署 Spring Boot 的,打成 jar 直接一键运行?打成 war 扔到 To ...

  9. stage_ros的world文件配置方法

    官方文档参阅:http://rtv.github.io/Stage/modules.html stage_ros是一个基于stage的2D模拟器,用于ROS的仿真测试.虽然现在越来越多的人在使用gaz ...

  10. 牛客小白月赛6 B 范围 数学

    链接:https://www.nowcoder.com/acm/contest/135/B来源:牛客网 题目描述 已知与均为实数,且满足: 给定A,B,求x的取值范围? 由于Apojacsleam的计 ...