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. 关于在Reshaper中添加代码模板代码段

    http://www.cnblogs.com/tristinjet/archive/2009/08/19/1550203.html 去 tools->模板中进行模板编辑设置

  2. C语言中typedef

    一.基本概念剖析 ])(int, char*); //#1 ]) (void (*)()); //#2 ]; //#3 .C语言中函数声明和数组声明.函数声明一般是这样: int fun(int, d ...

  3. zhihu spark集群,书籍,论文

    spark集群中的节点可以只处理自身独立数据库里的数据,然后汇总吗? 修改 我将spark搭建在两台机器上,其中一台既是master又是slave,另一台是slave,两台机器上均装有独立的mongo ...

  4. 【LeetCode练习题】Minimum Depth of Binary Tree

    Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the n ...

  5. Python 自动化脚本学习(一)

    Python 基础 命令行:在http://www.python.org安装python3,Mac下输入python3进入命令行 整数,浮点数,字符串类型:-1,0.1,'game' 字符串连接和复制 ...

  6. .Net语言中关于AOP 的实现详解

    来源: IT人家  发布时间: 2011-03-22 20:28  阅读: 3546 次  推荐: 2   原文链接   [收藏] 摘要:该文章主要和大家讲解开发应用系统时在.Net语言中关于AOP ...

  7. 使用java连接hive,并执行hive语句详解

    安装hadoop 和 hive我就不多说了,网上太多文章 自己看去 首先,在机器上打开hiveservice hive --service hiveserver -p 50000 & 打开50 ...

  8. EF MySQL 提示 Specified key was too long; max key length is 767 bytes错误

    在用EF的CodeFirst操作MySql时,提示 Specified key was too long; max key length is 767 bytes错误,但数据库和表也建成功了.有高人知 ...

  9. 使用XE5-PACTH破解Delphi-XE5时,出现检查文件大小失败的解决方法

    今天给自己的64位Win7电脑破解Delphi-XE5时,一直出现检查bds.exe尺寸大小失败的错误提示. 网上查了很久,Csdn上给了个破解的bds.exe,本人一直没什么Csdn积分,没得下,所 ...

  10. RabbitMQ消息队列安装和配置以及推送消息

    好久没有写了,最近项目用到RabbitMQ,找了一些资料试验,最后终于成功了,把安装配置的步骤分享给大家. 一.Erlang安装具体过程: 1.双击otp_win32_R16801.exe(不同版本可 ...