HDU2164 Rock, Paper, or Scissors?【水题】
来源:互联网 发布:在centos上安装jdk 编辑:程序博客网 时间:2024/05/16 06:52
Rock, Paper, or Scissors?
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2177 Accepted Submission(s): 1394
Problem Description
Rock, Paper, Scissors is a two player game, where each player simultaneously chooses one of the three items after counting to three. The game typically lasts a pre-determined number of rounds. The player who wins the most rounds wins the game. Given the number of rounds the players will compete, it is your job to determine which player wins after those rounds have been played.
The rules for what item wins are as follows:
?Rock always beats Scissors (Rock crushes Scissors)
?Scissors always beat Paper (Scissors cut Paper)
?Paper always beats Rock (Paper covers Rock)
Input
The first value in the input file will be an integer t (0 < t < 1000) representing the number of test cases in the input file. Following this, on a case by case basis, will be an integer n (0 < n < 100) specifying the number of rounds of Rock, Paper, Scissors played. Next will be n lines, each with either a capital R, P, or S, followed by a space, followed by a capital R, P, or S, followed by a newline. The first letter is Player 1抯 choice; the second letter is Player 2抯 choice.
Output
For each test case, report the name of the player (Player 1 or Player 2) that wins the game, followed by a newline. If the game ends up in a tie, print TIE.
Sample Input
3
2
R P
S R
3
P P
R S
S R
1
P R
Sample Output
Player 2
TIE
Player 1
Source
2007 ACM-ICPC Pacific Northwest Region
题目大意:两个人玩石头、剪刀、步,第一个人赢了输出"Player 1",第二个人赢了输出
"Player 2",平手了就输出"TIE"。
思路:用两个数计算他们两个人的次数,平了不计。谁赢得次数多算谁赢。相等就是平手。
#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>using namespace std;int main(){ int T; cin >> T; while(T--) { int N; cin >> N; char A,B; int NumA = 0,NumB = 0; for(int i = 0; i < N; ++i) { cin >> A >> B; if(A==B) continue; else if((A=='R'&&B=='S') || (A=='S'&&B=='P') || (A=='P'&&B=='R')) NumA++; else NumB++; } if(NumA == NumB) cout << "TIE" << endl; else if(NumA > NumB) cout << "Player 1" << endl; else cout << "Player 2" << endl; } return 0;}
0 0
- HDU2164 Rock, Paper, or Scissors?【水题】
- HDU2164:Rock, Paper, or Scissors?
- HDOJ 2164 Rock, Paper, or Scissors?(水题)
- Rock, Paper, or Scissors? 2164
- hdu 2164 Rock, Paper, or Scissors?
- JAVA hdu 2164 Rock, Paper, or Scissors?
- 1407281127-hd-Rock, Paper, or Scissors.cpp
- HDOJ(HDU) 2164 Rock, Paper, or Scissors?
- Rock-Paper-Scissors
- 【poj2339】Rock, Scissors, Paper
- Rock, Scissors, Paper
- 杭电acm-2164 Rock, Paper, or Scissors?
- poj 2339 Rock, Scissors, Paper
- POJ 2339 Rock, Scissors, Paper
- poj 3917 Rock, Paper, Scissors
- POJ-2339-Rock, Scissors, Paper
- poj 2339 Rock, Scissors, Paper
- POJ - 2339 Rock, Scissors, Paper
- Android 打造炫目的圆形菜单 秒秒钟高仿建行圆形菜单
- Android SQLite 一个工具类搞定基本的数据增删改查
- android sdk install
- 解决MDK中文注释乱码问题
- 100个iOS开发/设计面试题汇总,你将如何作答?
- HDU2164 Rock, Paper, or Scissors?【水题】
- ssh免密码登陆
- jstl中<c:forEach>的用法
- 用socket模拟php中get,post
- Python中sorted()方法的用法
- # 深入理解Java中为什么内部类可以访问外部类的成员#
- 关于SVN在Eclipse中的使用
- JAVA对文件操作的常用方法
- 添加库存