码迷,mamicode.com
首页 > 其他好文 > 详细

TOJ1804,模拟

时间:2014-07-28 00:29:30      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:des   style   http   color   os   strong   io   for   

原题http://acm.timus.ru/problem.aspx?space=1&num=1804

D - The Machinegunners in a Playoff
Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

The Machinegunners women‘s football team has advanced to the knockout stage of the Revolution Cup. The Cavalry team is their opponent in the first round.
According to the rules, the teams must play two games, one at the Machinegunners‘ stadium and the other at the Cavalry‘s stadium. The team that scores more goals in the two games will advance to the next round. If the teams score the same number of goals, then the team that scores more goals at the opponent‘s stadium will advance. If these numbers are also the same, then the winner will be chosen at random.
The teams have played their first game already. The Machinegunners want to work out an adequate tactics for the return game, and for this they need to know the following two values:
  • the minimal number of goals they must score to get a chance to advance to the next round;
  • the maximal number of goals they may score which leaves a chance for their opponents to advance to the next round.
It is known that no team can score more than thirty goals in one game.

Input

The input consists of several test cases. The first line contains the number of test cases t (1 ≤ t ≤ 200). Each of the following t lines describes one test case and contains the result of the first game in the form:
The Machinegunners played where game, scored x goals, and conceded y goals.
where where is the string “home” or “away”; 0 ≤ x, y ≤ 30.

Output

For each of test cases output in a separate line the minimal number of goals necessary to advance to the next round and the maximal number of goals that does not guarantee this.

Sample Input

input
2
The Machinegunners played home game, scored 28 goals, and conceded 0 goals.
The Machinegunners played home game, scored 1 goals, and conceded 1 goals.
output
0 1
1 29
#include <string.h>
#include <stdio.h>

int main()
{
    int t,a,b,i,j;
    char str[10];
    scanf("%d",&t);
    while(t--)
    {
     scanf("%*s%*s%*s%s%*s%*s%d%*s%*s%*s%d%*s",str,&a,&b);//%*s代表一个单词和一个字符串
        if(strcmp(str,"home") == 0)
        {
            for(i=0;i<=30;i++)
            {
                if(a+i > b)
                {
                    printf("%d ",i);
                    break;
                }
                else if(a+i == b && i>=b)
                {
                    printf("%d ",i);
                    break;
                }
            }
            for(i=30;i>=0;i--)
            {
                if(a+i < b+30)
                {
                    printf("%d\n",i);
                    break;
                }
                else if(a+i == b+30 && i<=b)
                {
                    printf("%d\n",i);
                    break;
                }
            }
        }
        else if(strcmp(str,"away")==0)
        {
            for(i=0;i<=30;i++)
            {
                if(a+i > b)
                {
                    printf("%d ",i);
                    break;
                }
                else if(a+i == b)
                {
                    printf("%d ",i);
                    break;
                }
            }
            for(i=30;i>=0;i--)
            {
                if(a+i<b+30 && i>= b)
                {
                    printf("%d\n",i);
                    break;
                }
                else if(a+i == b+30 && a <= 30)
                {
                    printf("%d\n",i);
                    break;
                }
            }
        }
    }
    return 0;
}


 

TOJ1804,模拟,布布扣,bubuko.com

TOJ1804,模拟

标签:des   style   http   color   os   strong   io   for   

原文地址:http://blog.csdn.net/zcr_7/article/details/38167531

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!