URAL 1804 The Machinegunners in a Playoff(模拟比赛得分)
来源:互联网 发布:java二级考试题库下载 编辑:程序博客网 时间:2024/06/05 10:16
1804. The Machinegunners in a Playoff
Time limit: 0.5 second
Memory limit: 64 MB
Memory limit: 64 MB
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
2The Machinegunners played home game, scored 28 goals, and conceded 0 goals.The Machinegunners played home game, scored 1 goals, and conceded 1 goals.
0 11 29
判断让自己赢的最小的自己的得分和让对方赢得的自己的最大得分,如果总得分情况一样,就看客场得分的情况。
AC代码:
#include <cstdio>#include <iostream>using namespace std;int main(){int t,x,y,flag,i;char a[152];scanf("%d",&t);getchar();while(t--){cin.getline(a,150);flag=1;for(i=43;i<150;i++){if(a[i]>='0'&&a[i]<='9'){if(flag){x=a[i]-'0';if(a[i+1]>='0'&&a[i+1]<='9'){x=x*10+a[i+1]-'0';i++;}flag=0;}else{y=a[i]-'0';if(a[i+1]>='0'&&a[i+1]<='9')y=y*10+a[i+1]-'0';break;}}}if(a[26]=='h'){if(x==0){if(y==0)printf("0 29\n");elseprintf("%d 30\n",y);}else if(x==30){if(y==30)printf("1 30\n");elseprintf("0 %d\n",y);}else{if(x==y)printf("1 29\n");else if(x<y)printf("%d 30\n",y-x+1);elseprintf("0 %d\n",30+y-x-1);}}else if(a[26]=='a'){if(x==y)printf("0 30\n");else if(x<y)printf("%d 30\n",y-x);elseprintf("0 %d\n",30+y-x);}}return 0;}
0 0
- URAL 1804 The Machinegunners in a Playoff(模拟比赛得分)
- ural 1804 The Machinegunners in a Playoff
- TOJ 1804 The Machinegunners in a Playoff
- URAL 1804 The Machinegunners in a Playoff (比较绕的分类)
- Goat in the Garden (ural 1348)
- CodeForces-719A. Vitya in the Countryside(模拟)
- URAL 2020. Traffic Jam in Flower Town(模拟)
- 【解题报告】 URAL 1192 Ball in a Dream -- 物理模拟水题
- URAL 1145. Rope in the Labyrinth(两次BFS啊 )
- ural 1998 The old Padawan (模拟+二分)
- 玲珑比赛 A -- chess play【记忆模拟】
- CodeForces 501A Contest(最大得分)
- ural 1084. Goat in the Garden
- ural 1348. Goat in the Garden 2
- ural 1084 Goat in the Garden
- Ural 1090. In the Army Now
- Ural 1090. In the Army Now
- ural 1090. In the Army Now
- 非常读一
- POJ2182 Lost Cows
- 非常读一
- 【FFT】大整数乘法
- 想入行的朋友看看这篇文章就大概知道游戏行业了
- URAL 1804 The Machinegunners in a Playoff(模拟比赛得分)
- 随机梯度下降法
- Cocos2d-x开发实例:单点触摸事件
- TOJ 1804 The Machinegunners in a Playoff
- JUnit的jar包和hamcrest的jar包关系
- oracle语句中如何把一列的值合并为一个值,用逗号隔开
- Period of an Infinite Binary Expansion+POJ+欧拉函数+好题
- hdu 1242 Rescue (bfs+优先队列)
- 都在放空间的身份卡老师家地方了开始觉得分