当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2232:New Stone-Forfex-Cloth Game

题目描述
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.
输入解释
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.
输出解释
For each case, output the total number of possible winners in a single line.
输入样例
3
C S F
2
S C
4
S S S S
输出样例
3
1
4

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 POJ Monthly,汪艺杰

源链接: POJ-2232

最后修改于 2020-10-29T06:27:12+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536