ZOJ2388 Beat the Spread! 2017-04-16 19:18 91人阅读 评论(0) 收藏
Beat the Spread!
Time Limit: 2 Seconds Memory Limit: 65536 KB
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 <iostream>
#include<queue>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<cstring>
using namespace std;
#define LL long long int main()
{
int a,b,T;
scanf("%d",&T);
while(T--)
{scanf("%d%d",&a,&b);
if((a+b)%2==1){
printf("impossible\n");
continue;
}
int x=(a+b)/2;
int y=a-x;
if(x<y)
swap(x,y);
if(x>=0&&y>=0)
printf("%d %d\n",x,y);
else
printf("impossible\n");
}
return 0;
}
ZOJ2388 Beat the Spread! 2017-04-16 19:18 91人阅读 评论(0) 收藏的更多相关文章
- 团体程序设计天梯赛L2-009 抢红包 2017-03-22 19:18 131人阅读 评论(0) 收藏
L2-009. 抢红包 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 没有人没抢过红包吧-- 这里给出N个人之间互相发红包.抢 ...
- Matlab调用C程序 分类: Matlab c/c++ 2015-01-06 19:18 464人阅读 评论(0) 收藏
Matlab是矩阵语言,如果运算可以用矩阵实现,其运算速度非常快.但若运算中涉及到大量循环,Matlab的速度令人难以忍受的.当必须使用for循环且找不到对应的矩阵运算来等效时,可以将耗时长的函数用C ...
- 滑雪 分类: POJ 2015-07-23 19:48 9人阅读 评论(0) 收藏
滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 83276 Accepted: 31159 Description Mich ...
- HDU6029 Happy Necklace 2017-05-07 19:11 45人阅读 评论(0) 收藏
Happy Necklace Time Limit: ...
- HDU6027 Easy Summation 2017-05-07 19:02 23人阅读 评论(0) 收藏
Easy Summation Time Limit: 2000/1000 MS ...
- The Pilots Brothers' refrigerator 分类: POJ 2015-06-15 19:34 12人阅读 评论(0) 收藏
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20304 ...
- IP Address 分类: POJ 2015-06-12 19:34 12人阅读 评论(0) 收藏
IP Address Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 19125 Accepted: 11053 Desc ...
- HDU6026 Deleting Edges 2017-05-07 19:30 38人阅读 评论(0) 收藏
Deleting Edges Time ...
- ZOJ2256 Mincost 2017-04-16 19:36 44人阅读 评论(0) 收藏
Mincost Time Limit: 2 Seconds Memory Limit: 65536 KB The cost of taking a taxi in Hangzhou is n ...
随机推荐
- Eclipse实用用快捷键
1.ctrl+shift+o 添加必须import并删除无用import.代码被改动时容易产生很多无用引用,此时这个快捷键就可以一次把如下的引用删掉了
- TF54000: 由于服务器时钟设置可能不正确,无法更新数据解决方案(补充)
此问题出现的原因: 服务器时间比本地时间大.由于TFS源代码的Source Control会根据签入时间做判断.如果后续签入的时间小于变更集的最新版本的时间,就会报错误“TF54000”,并拒绝签入. ...
- 转转转---js正则表达exec与match的区别说明
正则表达式对象有两个定义方式:: 1.第一种定义: new RegExp(pattern, attributes);如var reg = new RegExp("abc",&quo ...
- 花瓶使用笔记 (抓数据时,记得添加host,不然抓不了包的)
情况一: 有时候抓不了app的数据,那么把app的host 添加一下就可以了 proxy > SSL Proxying Settings 情况二: 开了 翻 墙 是抓不了包的! (掉了一次坑)
- win和linux下控制台界面中停顿X秒的方式
win localhost > nul linux
- 蚂蚁社招Java-第四轮电话面试【技术终面】
作者:听着歌过面试链接:https://www.nowcoder.com/discuss/64708来源:牛客网 蚂蚁社招Java-第四轮电话面试[技术终面] 转载 (耗时22分钟,其实聊得东西挺 ...
- nginx正向代理访问百度地图API
正向代理的概念 正向代理,也就是传说中的代理,他的工作原理就像一个跳板,简单的说,我是一个用户,我访问不了某网站,但是我能访问一个代理服务器这个代理服务器呢,他能访问那个我不能访问的网站于是我先连上代 ...
- ES6系列_12之map数据结构
1.map数据结构出现的原因? JavaScript 的对象(Object),本质上是键值对的集合(Hash 结构),但是传统上只能用字符串当作键.这给它的使用带来了很大的限制.为了能实现将对象作为键 ...
- JSF多列预选择
<script type="text/javascript"> jQuery(document).ready(function () { preSelect(); }) ...
- python中numpy计算数组的行列式numpy.linalg.det()
numpy.linalg.det numpy.linalg.det(a)[source] 计算任何一个数组a的行列式,但是这里要求数组的最后两个维度必须是方阵. 参数: a : (..., M, M) ...