杭电 HDU 1194 Beat the Spread!
来源:互联网 发布:javascript调用数据库 编辑:程序博客网 时间:2024/05/22 10:49
Beat the Spread!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5192 Accepted Submission(s): 2705
Problem 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?
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
240 2020 40
Sample Output
30 10impossible
#include<iostream>using namespace std;int main(){int t,a,b;cin>>t;while(t--){int x,y;cin>>a>>b;if(a<b||a<0||b<0||((a+b)%2!=0))cout<<"impossible"<<endl;else {x=(a+b)/2; y=(a-b)/2;if(x<y)swap(a,b);cout<<x<<" "<<y<<endl;}}return 0;}
0 0
- 杭电 HDU 1194 Beat the Spread!
- 杭电 OJ 1194 Beat the Spread!
- HDU 1194 Beat the Spread!
- HDU 1194 Beat the Spread!
- HDU 1194Beat the Spread!
- HDU 1194 Beat the Spread!
- hdu 1194 Beat the Spread!
- hdu-1194 Beat the Spread!
- hdu 1194 Beat the Spread!(水题)
- hdu-oj 1194 Beat the Spread!
- HDU 1194 Beat the Spread!(数学)
- HDU 1194 Beat the Spread! 【水题+细心】
- 1194:Beat the Spread!
- 1194 Beat the Spread!
- [1194]:Beat the Spread!
- 杭电ACM1194——Beat the Spread!
- HDOJ 1194 Beat the Spread!
- HDOJ 1194 Beat the Spread!
- Mysql 数据库热备份
- 移动开发者的小噩梦Google广告沦陷--android反编译实战
- 《Linux程序设计》初学感受,少量bug未能解决
- LINUX命令行如何查看memcache运行状态
- 设置response.setHeader时,含有中文字符,设置出现错误
- 杭电 HDU 1194 Beat the Spread!
- bcb中TServerSocket 多线程阻塞模式收发数据
- Java实现敏感词过滤
- android 周报
- 动态语言、动态类型语言、静态类型语言、强类型语言、弱类型语言
- response.setHeader()的用法
- 创新来自于?
- 块级元素以及行内元素居中显示
- ViewPager -----使用Fragment实现ViewPager滑动