Game
TimeLimit: 1 Second MemoryLimit: 32 Megabyte
Totalsubmit: 39 Accepted: 25
Description
Luke often plays the Rock-Paper-Scissors-game with Lucky, but Lucky is always the loser, the reason is that Lucky plays this game according to a particular rule every time. Today Luke wanted to play this game with Lucky again, but Lucky didn’t agree because she is tired of being a loser. So Luke and Lucky reached a compromise that if the result in a tie means Lucky is the winner, and the times Luke uses ‘rock’ cannot larger than R, uses ‘scissors’ cannot larger than S,uses ‘paper’ cannot larger than P. Luke wants to know in this case how many times he can win at most.Input
There are multiple test cases.In each test case, the first line is a string which only contains R, S and P , this string represents what Luke used in this game. R means Rocker, S mean Scissors, P means Paper. In the following line are three integers r, s, p.The sum of r,s,p is no less than the length of the string and the length of the string is no larger than 100.
Output
For each test case, first output a line “Case T:” T starts with 1. And then output the times he can win at most.Sample Input
RRPRSSRPP
1 5 4
PSRPRSSS
100 0 0
R
100 100 0
Sample Output
Case 1:
8
Case 2:
4
Case 3:
0
#include<stdio.h>
char str [100] ;
int count=1;
int getMin(int x,int y)
{
if(x<=y)
return x ;
else
return y ;
}
int main()
{
while (scanf("%s",&str)!=EOF)
{
int i;
int R,S,P;
scanf("%d %d %d",&R,&S,&P);
int r=0,s=0,p=0;
for(i=0;i<strlen(str);i++)
{
if (str[i]=='R')
p++;
else if (str[i]=='S')
r++;
else if (str[i]=='P')
s++;
}
int sum =getMin(S,s)+getMin(P,p)+getMin(R,r);
printf("Case %d:\n%d\n",count++,sum);
}
}