poj2301beat the spread
来源:互联网 发布:上海日式拉面 知乎 编辑:程序博客网 时间:2024/05/16 23:42
/*题意就是第一个是两数和,第二个是差,求那两个数。。话说题确实不难,不过我第一次用的循环,感觉就不对,事实真不对。原来大神是这么做的
哎呀,数学不行真不行,有压力啊,和差相加,和差相减 然后除以二*/
/*Description
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?
Input
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.
Output
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.
Sample Input
2
40 20
20 40
Sample Output
30 10
impossible
*/
哎呀,数学不行真不行,有压力啊,和差相加,和差相减 然后除以二*/
#include<stdio.h>int main(){ int sum, dif, t; scanf_s("%d", &t); while (t--) { scanf_s("%d %d", &sum, &dif); if ((sum + dif) % 2 == 1 || dif>sum) printf_s("impossible\n"); else printf_s("%d %d\n", (sum + dif) / 2, (sum - dif) / 2); } return 0;}
/*Description
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?
Input
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.
Output
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.
Sample Input
2
40 20
20 40
Sample Output
30 10
impossible
*/
0 0
- poj2301beat the spread
- Beat the Spread!
- zoj2388Beat the Spread!水题
- Beat the Spread! (P2301)
- zoj2388----------------Beat the Spread!
- HDU1194:Beat the Spread!
- 10812 - Beat the Spread!
- zoj_2388 Beat the Spread!
- hdu1194-Beat the Spread!
- zoj Beat the Spread!
- HDU1194_Beat the Spread!
- zoj2388 Beat the Spread!
- Beat the Spread!
- Beat the Spread!
- 1194:Beat the Spread!
- 1194 Beat the Spread!
- [1194]:Beat the Spread!
- hdu1194Beat the Spread!
- s3c2440中断分析(转)
- 是的,所有人都在笑
- startos安装apache,php,mysql
- UVA 103 Stacking Boxes
- 14 .Magento备份 rsyncd +inotify 即时备份
- poj2301beat the spread
- 防止页面的重复提交,刷新
- Hive+UDAF简单示例
- 储存班长信息的学生类
- 微信客服之qq消息提醒
- c++学习笔记4,派生类的构造函数与析构函数的调用顺序(一)
- 深入探索spring技术内幕(八): Spring +JDBC组合开发和事务控制
- PAT2-07 素因子分解
- OCP 1Z0 051 48