ZOJ 2388 Beat the Spread!
来源:互联网 发布:tgp检测网络环境异常 编辑:程序博客网 时间:2024/06/03 23:05
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?
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.
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.
2
40 20
20 40
30 10
impossible
简单题,判断一下即可。
#include<bits/stdc++.h>using namespace std;int main(){ int n; cin>>n; while(n--) { long long a,b; cin>>a>>b; if ((a+b)%2) puts("impossible"); else { long long c=(a+b)/2; long long d=a-c; if (c<0||d<0) puts("impossible"); else cout<<c<<" "<<d<<endl; } } return 0;}
- ZOJ 2388 Beat the Spread!
- zoj 2388 Beat the Spread!
- ZOJ 2388 Beat the Spread!
- ZOJ 2388 Beat the Spread!
- zoj Beat the Spread!
- ZOJ Problem Set - 2388 Beat the Spread!
- zoj 2388.Beat the Spread!
- Beat 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!
- zoj2388 Beat the Spread!
- Beat the Spread!
- Beat the Spread!
- 1194:Beat the Spread!
- GitHub 添加jar包
- 【复杂网络学习笔记】1:基本知识和小世界网络初步建立
- 深入研究windows内部原理系列---笔记1
- 《统计学习方法》——对偶感知器的python实现
- uva1600 -- Patrol Robot
- ZOJ 2388 Beat the Spread!
- 48. Rotate Image
- Android开发中的小技巧(1)
- ZOJ 2208 To and Fro
- 基于空间相关的图像模板匹配及MATLAB实现
- jdk环境的配置
- 【C语言】常用的转义字符及其含义
- android学习笔记(4)
- 一条sql语句分组、升序、指定条数查询