2013
12-30

# Rock, Paper, or Scissors?

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)

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.

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.

3
2
R P
S R
3
P P
R S
S R
1
P R

Player 2
TIE
Player 1
#include"stdio.h"
int main()
{
int t;
int n;
char c1,c2;
int a,b,i;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
getchar();
a=b=0;
for(i=0;i<n;i++)
{
scanf("%c %c",&c1,&c2);
getchar();
if(c1=='R')
{
if(c2=='S')a++;
else if(c2=='P')b++;
}
else if(c1=='S')
{
if(c2=='P')a++;
else if(c2=='R')b++;
}
else if(c1=='P')
{
if(c2=='R')a++;
else if(c2=='S')b++;
}
}
if(a>b)printf("Player 1\n");
else if(a==b)printf("TIE\n");
else if(a<b)printf("Player 2\n");
}
return 0;
}

1. 第23行：
hash = -1是否应该改成hash[s ] = -1

因为是要把从字符串s的start位到当前位在hash中重置

修改提交后能accept，但是不修改居然也能accept

2. 因为是要把从字符串s的start位到当前位在hash中重置，修改提交后能accept，但是不修改居然也能accept

3. 为什么for循环找到的i一定是素数叻，而且约数定理说的是n=p1^a1*p2^a2*p3^a3*…*pk^ak，而你每次取余都用的是原来的m，也就是n