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>
using namespace std;
int main(){
int n, s, d;
//x + y = s;
//x - y = d;
int x, y;//因为是绝对差,所以直接假定x大,y小
cin >> n;
while(n--){
cin >> s >> d;
//x,y必须为整数,由方程得2x = s + d;故s + d为偶数
if((s + d) % != ){
cout << "impossible" << endl;
continue;
}
else
x = (s + d) / ;
y = s - x;
if(y < )
cout << "impossible" << endl;
else
cout << x << " " << y << endl;
}
return ;
}

zoj 2388 Beat the Spread!的更多相关文章

  1. Beat the Spread![HDU1194]

    Beat the Spread! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

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

  3. HDOJ 1194 Beat the Spread!(简单题)

    Problem Description Superbowl Sunday is nearly here. In order to pass the time waiting for the half- ...

  4. HDU 1194 - Beat the Spread!

    给两数之和和两数之差,求两数,两数还必须同奇偶 #include <iostream> using namespace std; int main() { int a,b,t; cin&g ...

  5. UVa 10812 - Beat the Spread!

    题目大意:知道一场橄榄球比赛比分的和以及差的绝对值,算出这两个数.注意判断结果的可能性(比分为非负数). #include <cstdio> int main() { #ifdef LOC ...

  6. HDU1194_Beat the Spread!

    Beat the Spread! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  7. 转载 ACM训练计划

    leetcode代码 利用堆栈:http://oj.leetcode.com/problems/evaluate-reverse-polish-notation/http://oj.leetcode. ...

  8. ACM学习

    转:ACM大量习题题库   ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库.   US ...

  9. (转载)ACM训练计划,先过一遍基础再按此拼搏吧!!!!

    ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. USACO ht ...

随机推荐

  1. Asp_基础之C#基础

    1.两个练习题 1)编程实现46天,是几周几天 int days = 46: int weeks = days / 7: int day =days % 7: //Console.WriteLine( ...

  2. React Native 手工搭建环境 之iOS篇

    常识 React native 开发服务器 在开发时,我们的框架是这样的:  当正式发布进入到生产环境时,开发服务器上所有的js文件将会被编译成包的形式,直接嵌入到客户端内.这时,已经不再需要开发服 ...

  3. apache下设置域名多站点访问及禁止apache访问80端口

    apache下设置域名多站点访问 当前系统:macOS High Sierra 域名访问配置指定端口后,不同域名只能配置不同的端口 apache配置目录: sudo vim /etc/apache2/ ...

  4. MySQL字符集和排序介绍

    客服端字符集: character_set_client utf8mb4连接字符集: character_set_connection utf8mb4数据库字符集: character_set_dat ...

  5. SQLServer查询死锁

    --查询死锁 select request_session_id spid, OBJECT_NAME(resource_associated_entity_id) tableName from sys ...

  6. 一个batch如何通过一个网络

    一个batch下所有的图片一起经过整个网络,不是说一张图片经过网络后再让下一张进入网络,这样一个batch一起通过网络计算速度比一张一张这样快

  7. python:lambda、filter、map、reduce

    lambda 为关键字.filter,map,reduce为内置函数. lambda:实现python中单行最小函数. g = lambda x: x * 2 #相当于 def g(x): retur ...

  8. 模板类 vector

    概要 介绍一下模板类 vector 的常用操作,以及一个应用举例,顺时针打印矩阵.   基本定义 模板类 vector 是一种动态数组,它是使用 new 创建动态数组的替代品,实际上,vector 也 ...

  9. QT+动手设计一个登陆窗口+布局

    登陆窗口的样式如下: 这里面涉及着窗口的UI设计,重点是局部布局和整体布局, 首先在ui窗口上添加一个容器类(Widget),然后将需要添加的控件放置在容器中,进行局部布局(在进行局部布局的时候可以使 ...

  10. python基础面试题整理---从零开始 每天十题(04)

    一.Q:如何用Python来进行查询和替换一个文本字符串? A:可以使用sub()方法来进行查询和替换,sub方法的格式为:sub(replacement, string[, count=0]) re ...