HDU2164:Rock, Paper, or Scissors?
2013-04-11 11:52
465 查看
[align=left]Problem Description[/align]
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
狂刷水题
我都不好意思做解题报告了
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
狂刷水题
我都不好意思做解题报告了
#include <stdio.h> int fun(char a,char b) { if((a == 'R' && b == 'S') || (a == 'S' && b == 'P') || (a == 'P' && b == 'R')) return 1; return 0; } int main() { int n,m; char a,b; scanf("%d",&m); while(m--) { int suma = 0,sumb = 0; scanf("%d%*c",&n); while(n--) { scanf("%c %c",&a,&b); getchar(); suma+=fun(a,b); sumb+=fun(b,a); } if(suma > sumb) printf("Player 1\n"); else if(suma == sumb) printf("TIE\n"); else printf("Player 2\n"); } }
相关文章推荐
- HDU2164 Rock, Paper, or Scissors?【水题】
- HDU2164:Rock, Paper, or Scissors?
- hdu 2164 Rock, Paper, or Scissors?
- HDOJ(HDU) 2164 Rock, Paper, or Scissors?
- JAVA hdu 2164 Rock, Paper, or Scissors?
- HDOJ 2164 Rock, Paper, or Scissors?(水题)
- Rock, Paper, or Scissors? 2164
- 杭电acm-2164 Rock, Paper, or Scissors?
- HDU 2164 Rock, Paper, or Scissors?
- HDOJ(HDU) 2164 Rock, Paper, or Scissors?
- Mini-project # 1 - Rock-paper-scissors-lizard-Spock
- (FFT)HDU 6088(2017 多校第5场 1004)Rikka with Rock-paper-scissors
- K - Yet Another Story of Rock-paper-scissors
- ZOJ3610-Yet Another Story of Rock-paper-scissors
- ZQUOJ1396 Rock, Scissors, Paper 解题报告
- Rock-Paper-Scissors
- 1 paper-rock-scissors-lizard-spock
- [DP 博弈] Topcoder SRM579 Div1. RockPaperScissors
- hdu 6088 Rikka with Rock-paper-scissors (2017 多校第五场 1004) 【组合数学 + 数论 + 模意义下的FFT】
- HDU 6088 - Rikka with Rock-paper-scissors | 2017 Multi-University Training Contest 5