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. C# 获取当前应用程序的绝对路径支持asp.net

      Asp.net在类库中获取某文件的绝对路径.这个问题在初学的时候就经常碰到过,经常是查了忘,忘了查.浪费了大量的今天专门写个文章,以后到这里查.有时间顺便记得研究下这个东西. 在主程序目录就不说了 ...

  2. C# attribute_特性

    特性的定义:公共语言运行时允许添加类似关键字的描述声明,叫做attribute,它对程序中的元素进行标注,如类型.字段.方法.和属性等.attribute和.NetFramework文件的元数据保存在 ...

  3. sizeof与类,继承,virtual的种种(整理)

    对虚继承层次的对象的内存布局,在不同编译器实现有所区别. 首先,说说GCC的编译器. 它实现比较简单,不管是否虚继承,GCC都是将虚表指针在整个继承关系中共享的,不共享的是指向虚基类的指针. clas ...

  4. HDOJ-1014 Uniform Generator

    http://acm.hdu.edu.cn/showproblem.php?pid=1014 给出式子seed(x+1) = [seed(x) + STEP] % MOD seed初始为0,给出STE ...

  5. hdu 5493 Queue(线段树)

    Problem Description N people numbered to N are waiting in a bank for service. They all stand in a qu ...

  6. One Way Roads(搜索)

    One Way Roads Time Limit:500MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit S ...

  7. poj 3308 (最大流)

    题意:n*m的地图,给出L个火星人登陆的坐标,要在火星人登陆地球的瞬间全部消灭他们,有一种激光枪,一次可以消灭一行(或一列),消灭一行(或一列)有不同的代价,总代价是所有激光枪的代价之积. 思路:之前 ...

  8. nand烧写分析/内核在启动过程中式如何将这个文件映射成/目录及各子目录的?

    我用的是ramdisk.image.gz,烧写在flash的0x10140000处 我不太明白内核在启动过程中式如何将这个文件映射成/目录及各子目录的? 如果ramdisk.image.gz在flas ...

  9. Android系统匿名共享内存(Anonymous Shared Memory)C++调用接口分析

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6939890 在Android系统中,针对移动设 ...

  10. C++ 实现Trim

    一.字符串去空格(没有处理字符串中间的空格) lTrim:除去字符串开头的空格 eg."    abc123    " --> "abc123    " ...