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) 收藏的更多相关文章

  1. 团体程序设计天梯赛L2-009 抢红包 2017-03-22 19:18 131人阅读 评论(0) 收藏

    L2-009. 抢红包 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 没有人没抢过红包吧-- 这里给出N个人之间互相发红包.抢 ...

  2. Matlab调用C程序 分类: Matlab c/c++ 2015-01-06 19:18 464人阅读 评论(0) 收藏

    Matlab是矩阵语言,如果运算可以用矩阵实现,其运算速度非常快.但若运算中涉及到大量循环,Matlab的速度令人难以忍受的.当必须使用for循环且找不到对应的矩阵运算来等效时,可以将耗时长的函数用C ...

  3. 滑雪 分类: POJ 2015-07-23 19:48 9人阅读 评论(0) 收藏

    滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 83276 Accepted: 31159 Description Mich ...

  4. HDU6029 Happy Necklace 2017-05-07 19:11 45人阅读 评论(0) 收藏

    Happy Necklace                                                                           Time Limit: ...

  5. HDU6027 Easy Summation 2017-05-07 19:02 23人阅读 评论(0) 收藏

    Easy Summation                                                             Time Limit: 2000/1000 MS ...

  6. 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 ...

  7. IP Address 分类: POJ 2015-06-12 19:34 12人阅读 评论(0) 收藏

    IP Address Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 19125   Accepted: 11053 Desc ...

  8. HDU6026 Deleting Edges 2017-05-07 19:30 38人阅读 评论(0) 收藏

    Deleting Edges                                                                                  Time ...

  9. 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 ...

随机推荐

  1. ASP.NET 执行bat文件。

    参考代码: http://blog.csdn.net/youngivan/article/details/7722384 在VS开发环境上是 网站应用程序能够正常执行bat,在winServer服务器 ...

  2. C#中XML文档注释编译DLL引用到其它项目

    引用地址:http://zhidao.baidu.com/link?url=jSGYEBysE4gBExtNsHCVk3vd2OK2cMlaf02cS79GdRuGueTBdFJB0btOdBYkg_ ...

  3. bzoj 3059: 归途与征程

    Description 给出一个长度为N的由小写字母’a’~’z’和’*’组成的字符串A,一个长度为M的仅由小写字母’a’~’z’组成的字符串B.一个’*’可以匹配任意多个字符(包括0个).求在B的所 ...

  4. 学习blus老师js(2)--深入JavaScript

    1.函数传参 可变参(不定参):arguments 参数的个数可变,参数数组   例1.求和 求所有参数的和 <!DOCTYPE HTML> <html> <head&g ...

  5. 实时计算CEP

    实时计算怎么实现: 流计算.....

  6. 开启php的xdebug扩展及phpstorm配置xdebug,chrome调试插件组合

    一. 开启php xdebug扩展      注意:     1. 原生php各版本需对应各自的xdebug版本,可到xdebug上对应下载     2. 若用wampserver等环境,wampse ...

  7. HTTP 协议基础

    HTTP 协议的主要特点可概括如下: 1.支持客户/服务器模式. 2.简单快速:客户向服务器请求服务时,只需传送请求方法和路径.请求方法常用的有GET.HEAD.POST.每种方法规定了客户与服务器联 ...

  8. javascript 特定字符分隔字符串函数

    function fn(num,div,token){//num需要分割的数字,div多少位分割 token分割字符 num=num+'',div=div||3,token=token||',' re ...

  9. vba截屏保存

    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVa ...

  10. 删除.svn 文件

    新建一个delete_svn.bat文件 @echo on color 2f mode con: cols= lines= @REM @echo 正在清理SVN文件,请稍候...... @rem 循环 ...