URAL 1804 The Machinegunners in a Playoff (比较绕的分类)
来源:互联网 发布:阿富汗 帝国坟场 知乎 编辑:程序博客网 时间:2024/06/09 13:57
题目链接:URAL 1804 The Machinegunners in a Playoff
题意:给出M队上一场(主场或客场)得分和失分(对方进球),求下一场M队的比赛策略
比赛的规则:2场比赛,两队分别依次主场。1.总分大的胜利。2.总分相同,客场得分多的胜利。3.两者都相同,两队都有可能获胜。每队一场得分不超过30分
策略:1.M队可能晋级的最小分数,2.M队使C队可能晋级的最大分数。
思路:求最小:C队得分0。求最大:C队得分30分。关键是比较每次两队的客场得分。
AC代码:
#include<stdio.h>#include<string.h>int main(){int a,b;int t,i,min,max;char s[10][100];while(scanf("%d",&t)!=EOF){while(t--){scanf("%s%s%s%s%s%s %d %s%s%s %d %s",s[0],s[1],s[2],s[3],s[4],s[5],&a,s[6],s[7],s[8],&b,s[9]);if(strcmp(s[3],"home")==0)//Machinegunners主场{//a+x=bmin=b-a;//总球数相同 M客场进min球 C客场进b球if(min>=0 && min<b)min++;else if(min<0)min=0;//a+max=b+30max=30+b-a;//总球数相同 M客场进max球 C客场进b球if(max<=30 && max>b)max--;else if(max>30)max=30;}else{min=b-a;//总球数相同 M客场进a球 C客场进0球if(min>=0 && a<0)min++;else if(min<0)min=0;//a+max=b+30max=30+b-a;if(max<=30 && a>30)max--;else if(max>30)max=30;}printf("%d %d\n",min,max);}}return 0;}/*10The Machinegunners played home game, scored 30 goals, and conceded 30 goals.The Machinegunners played away game, scored 30 goals, and conceded 30 goals.The Machinegunners played home game, scored 3 goals, and conceded 3 goals.The Machinegunners played away game, scored 3 goals, and conceded 5 goals.The Machinegunners played away game, scored 30 goals, and conceded 0 goals.*/
AC代码(模拟)
详细:http://blog.csdn.net/kewowlo/article/details/38149569
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int Min(int a,int b){return a>b?b:a;}int main(){int a,b;int t,len,i,m;char s[10][100];while(scanf("%d",&t)!=EOF){while(t--){scanf("%s%s%s%s%s%s %d %s%s%s %d %s",s[0],s[1],s[2],s[3],s[4],s[5],&a,s[6],s[7],s[8],&b,s[9]);if(strcmp(s[3],"home")==0)//Machinegunners主场{//a赢求,b是输球for(i=0;i<=30;i++){if(i+a>b){printf("%d ",i);break;}else if(i+a==b && i>=b){printf("%d ",i);break;}}for(i=30;i>=0;i--){if(i+a<b+30){printf("%d\n",i);break;}else if(i+a==b+30 && i<=b){printf("%d\n",i);break;}}}else//客场{for(i=0;i<=30;i++){if(i+a>b){printf("%d ",i);break;}else if(i+a==b){printf("%d ",i);break;}}for(i=30;i>=0;i--){if(i+a<b+30 && i>=b){printf("%d\n",i);break;}else if(i+a==b+30 && a<=30){printf("%d\n",i);break;}}}}}return 0;}/*2The Machinegunners played home game, scored 29 goals, and conceded 4 goals.The Machinegunners played away game, scored 0 goals, and conceded 0 goals.The Machinegunners played home game, scored 3 goals, and conceded 3 goals.The Machinegunners played away game, scored 3 goals, and conceded 5 goals.The Machinegunners played away game, scored 30 goals, and conceded 0 goals.0 00 2930 301 30*/
1 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(模拟比赛得分)
- ural 1084. Goat in the Garden
- ural 1348. Goat in the Garden 2
- ural 1084 Goat in the Garden
- Goat in the Garden (ural 1348)
- Ural 1090. In the Army Now
- Ural 1090. In the Army Now
- ural 1090. In the Army Now
- URAL 1090. In the Army Now
- URAL - 1145 Rope in the Labyrinth
- ural 1084. Goat in the Garden math
- URAL-1101. Robot in the Field
- URAL 1192. Ball in a Dream
- URAL 1075. Thread in a Space
- URAL 1285 Thread in a Hyperspace
- 水仙花数
- 各种浏览器内核介绍
- ORACLE日期函数大全
- 验证数字或者小数
- 如何用 MySQL 进行存储过程编写,以用户登陆为例,结构清晰,涵盖内容很多
- URAL 1804 The Machinegunners in a Playoff (比较绕的分类)
- 查看LINUX进程内存情况的命令
- const常量
- ORACLE中decode函数的用法
- 相遇是缘
- Floyd
- 4、确定对象在使用前已被初始化
- 如何通过函数调用得到n个要改变的值(摘抄自谭浩强C语言)
- 求哈夫曼树的带权路径长