Beat the Spread!
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 17794   Accepted: 8484

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

Source

水题,唯一要注意的就是x和y如果一个是偶数一个是奇数也应该impossible,这题在今年的中国地质大学邀请赛上面有一个类似的,不过那个难多了。需要二分
 #include<iostream>
#include<cstdio>
using namespace std; int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int x,y;
for(int i= ;i<n;i++)
{
scanf("%d%d",&x,&y);
if(x<y||x%==&&y%!=||x%!=&&y%==)
printf("impossible\n");
else
{
int larger = (x+y)/;
int litter = x-larger;
printf("%d %d\n",larger,litter);
}
}
}
return ;
}

poj2301的更多相关文章

  1. POJ2301+水~~~~~~

    有比这更水的么.............. #include<stdio.h> int main(){ int n; scanf("%d",&n); while ...

随机推荐

  1. 仿新浪微博短网址PHP实现方案

    微博限制140字,但是我们知道有时需要分享一个类似淘宝商品的链接,很长,为了避免这个问题,所有了短网址的概念,废话不多说,直接把我的实现方案分享一下: 1)将长网址md5生成32位签名串,分为4段, ...

  2. nc命令总结

    1.远程拷贝文件从server1拷贝文件到server2上.需要先在server2上,用nc激活监听,server2上运行: 引用 [root@hatest2 tmp]# nc -l 1234 > ...

  3. HttpClient连接池抛出大量ConnectionPoolTimeoutException: Timeout waiting for connection异常排查

    转自: http://blog.csdn.net/shootyou/article/details/6615051 今天解决了一个HttpClient的异常,汗啊,一个HttpClient使用稍有不慎 ...

  4. distinct() 去重复

    distinct 是对整个结果集进行数据重复抑制,而不是针对每一个列. select distinct FDepartment from T_Employee

  5. 论文:network embedding

    KDD2016: network embedding model: deep walk(kdd 2014): http://videolectures.net/kdd2014_perozzi_deep ...

  6. Unity position和localposition

    1. position是根据世界原点为中心 2. localPosition是根据父节点为中心,如果没有父节点,localpositon和position是没有区别的 3.选中一个物体左上角Globa ...

  7. Alexandra and Prime Numbers(思维)

    Alexandra and Prime Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (J ...

  8. Hive的UDF实现及注意事项

    Hive自身查询语言HQL能完毕大部分的功能,但遇到特殊需求时,须要自己写UDF实现.下面是一个完整的案例. 1.eclipse中编写UDF ①项目中增加hive的lib下的全部jar包和Hadoop ...

  9. Java凝视Annotation

     Java凝视Annotation 从JDK 5開始,Java添加了对元数据(MetaData)的支持,也就是Annotation(凝视).Annotation提供了一种为程序元素设置元数据的方法 ...

  10. lua实现多继承

    http://my.oschina.net/u/156466/blog/401576local class1 = {} function class1:new() local obj = {} set ...