辽宁赛区热身赛A-Game

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);
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值