HDU1194 POJ2301 UVA10812 ZOJ2388 Beat the Spread!【数学】
2017-12-09 07:24
555 查看
Beat the Spread!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7508 Accepted Submission(s): 3961
[align=left]Problem Description[/align]Superbowl Sunday is nearly here. In order to pass the time waiting for the half-time commercials and wardrobe malfunctions, the local hackers have organized a betting pool on the game. Members place their bets on the sum of the two final scores, or on the absolute difference between the two scores.
Given the winning numbers for each type of bet, can you deduce the final scores?
[align=left]Input[/align]The first line of input contains n, the number of test cases. n lines follow, each representing a test case. Each test case gives s and d, non-negative integers representing the sum and (absolute) difference between the two final scores.
[align=left]Output[/align]For each test case, output a line giving the two final scores, largest first. If there are no such scores, output a line containing "impossible". Recall that football scores are always non-negative integers.
[align=left]Sample Input[/align]2
40 20
20 40
[align=left]Sample Output[/align]30 10
impossible
[align=left]Source[/align]University of Waterloo Local Contest 2005.02.05
问题链接:HDU1194 POJ2301 UVA10812 ZOJ2388 Beat the Spread!
问题简述:(略)
问题分析:这是一个数学计算问题,看程序解释。
程序说明:(略)
题记:(略)
参考链接:(略)
AC的C语言程序如下:/* HDU1194 POJ2301 UVA10812 ZOJ2388 Beat the Spread! */
#include <stdio.h>
int main(void)
{
int n, s, d; /* s表示和,d表示差的绝对值 */
scanf("%d", &n);
while(n--) {
scanf("%d%d", &s, &d);
if(s < d)
/* 数是整数,和不可能小于差的绝对值 */
printf("impossible\n");
else if((s + d) % 2 != 0)
/* 和与绝对值的差必须同奇偶 */
printf("impossible\n");
else
/* 设x,y(x>y)的和与差分别是s和d,那么x=(s+d)/2,y=(s-d)/2 */
printf("%d %d\n", (s + d) / 2, (s - d) / 2);
}
return 0;
}
相关文章推荐
- UVa 10812 Beat the Spread! (陷阱)
- UVa 10812 Beat the Spread!
- UVa 10812 - Beat the Spread!
- UVa 10812 - Beat the Spread!
- UVa 10812 - Beat the Spread!
- hdoj 1194 Beat the Spread!(数学题)
- hdu1194-Beat the Spread!
- HDU 1194 Beat the Spread!(数学)
- 10812 - Beat the Spread!
- Beat the Spread![HDU1194]
- HDU1194:Beat the Spread!
- 10812 - Beat the Spread!
- [结题报告]10812 - Beat the Spread! Time limit: 3.000 seconds
- HDU 1194 Beat the Spread!(数学问题呀..)
- ZOJ2388 Beat the Spread!
- ZOJ2388-Beat the Spread!
- hdu1194 Beat the Spread!
- UVa 11300 Spreading the Wealth 数学题
- Beat the Spread!
- Uva 11752 The Super Powers 解题报告(数学)