poj-2232 New 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
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
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 思维题的更多相关文章
- 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 ...
- [NOIP2005] 过河【Dp,思维题,缩点】
Online Judge:Luogu P1052 Label:Dp,思维题,缩点,数学 题目描述 在河上有一座独木桥,一只青蛙想沿着独木桥从河的一侧跳到另一侧.在桥上有一些石子,青蛙很讨厌踩在这些石子 ...
- zoj 3778 Talented Chef(思维题)
题目 题意:一个人可以在一分钟同时进行m道菜的一个步骤,共有n道菜,每道菜各有xi个步骤,求做完的最短时间. 思路:一道很水的思维题, 根本不需要去 考虑模拟过程 以及先做那道菜(比赛的时候就是这么考 ...
- cf A. Inna and Pink Pony(思维题)
题目:http://codeforces.com/contest/374/problem/A 题意:求到达边界的最小步数.. 刚开始以为是 bfs,不过数据10^6太大了,肯定不是... 一个思维题, ...
- ZOJ 3829 贪心 思维题
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829 现场做这道题的时候,感觉是思维题.自己智商不够.不敢搞,想着队友智商 ...
- 洛谷P4643 [国家集训队]阿狸和桃子的游戏(思维题+贪心)
思维题,好题 把每条边的边权平分到这条边的两个顶点上,之后就是个sb贪心了 正确性证明: 如果一条边的两个顶点被一个人选了,一整条边的贡献就凑齐了 如果分别被两个人选了,一作差就抵消了,相当于谁都没有 ...
- 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 ...
- PJ考试可能会用到的数学思维题选讲-自学教程-自学笔记
PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数 ...
- 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 ...
- cf796c 树形,思维题
一开始以为是个树形dp,特地去学了..结果是个思维题 /* 树结构,设最大点权值为Max,则答案必在在区间[Max,Max+2] 证明ans <= Max+2 任取一个点作为根节点,那么去掉这个 ...
随机推荐
- HDU 1847
题意略. 思路:又忘了dp,搜索这种暴力方法了.... #include<bits/stdc++.h> using namespace std; ; bool sg[maxn]; int ...
- Java基础之访问权限控制
Java基础之访问权限控制 四种访问权限 Java中类与成员的访问权限共有四种,其中三种有访问权限修饰词:public,protected,private. Public:权限最大,允许所有类访问,但 ...
- 12_goto语句的使用
1.goto是一个关键字,其作用是运行到goto语句进行跳转,立即执行goto后面所对应标签的语句2.结构:goto 标签名(任意起)3.goto语句尽量不要跨函数使用,否则会使代码看起来非常乱,可读 ...
- Java连载24-break语句、continue语句、输出质数练习
一.break 1.break是Java语言中的关键字,被翻译为“中断/折断” 2.break + ";"可以成为一个单独的完整的java语句: break; 3.break语 ...
- 数据结构C线性表现实
linearList.h #ifndef _INC_STDIO_8787 #define _INC_STDIO_8787 #include <stdio.h> #include <m ...
- HTML(三)链接,<head>,css样式
HTML链接 HTML 超链接 一个未访问过的链接显示为蓝色字体并带有下划线 访问过的链接显示为紫色并带有下划线 点击链接时,链接显示为红色并带有下划线 注意:如果为这些超链接设置了 CSS 样式,展 ...
- (五十八)c#Winform自定义控件-管道阀门(工业)
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...
- python控制窗口移动(画圆)
import win32con import win32gui import time import math notepad = win32gui.FindWindow("Notepad& ...
- [普及]NOIP 2015 推销员 贪心
NOIP 2015 推销员 题意: 有一个喜欢疲劳的推销员,告诉你在一个单口胡同(数轴)中的n户家庭的位置,和向他们推销可以获得的疲劳度.分别输出向(1,2,3,4...n)户人家推销可以得到的最大疲 ...
- CF1003D Coins and Queries 贪心
Coins and Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...