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. Ajax 提交表单【包括文件上传】

    利用js插件实现 <script src="@Url.Content("~/js/layer/jquery.form.min.js")"></ ...

  2. [转]Java8 lambda表达式及新特新

    分享自:Vincent package info.liuwenjun.test; import org.junit.Test; import java.util.*; import java.util ...

  3. 实现dedecms(PC端)全站动态浏览 并实现伪静态

    dedecms默认是生成静态文件,如何实现织梦(PC端)全站动态浏览呢? 织梦全站动态浏览方法 1. 修改首页为动态浏览 后台-生成-更新首页-勾选“仅动态浏览” 2. 修改栏目页为动态浏览 ①添加或 ...

  4. 【数据分析 R语言实战】学习笔记 第八章 方差分析与R实现

    方差分析泛应用于商业.经济.医学.农业等诸多领域的数量分析研究中.例如商业广告宣传方面,广告效果可能会受广告式.地区规模.播放时段.播放频率等多个因素的影响,通过方差分析研究众多因素中,哪些是主要的以 ...

  5. java中的堆与栈

    Java 中的堆和栈 Java把内存划分成两种:一种是栈内存,一种是堆内存. 在函数中定义的一些基本类型的变量和对象的引用变量都在函数的栈内存中分配 . 当在一段代码块定义一个变量时,Java就在栈中 ...

  6. Servlet The Request

    The Request HTTP Protocol Parameters 所有的HTTP Protocol Parameters都会放在一个Map中, 可以通过getParameterMap得到. 对 ...

  7. Python 中函数(Function)的用法

    函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 函数能提高应用的模块性,和代码的重复利用率.Python提供了许多内建函数,比如print().input(),也可以自己创建函数, ...

  8. 爬虫5_python2_使用 Beautiful Soup 解析数据

    使用 Beautiful Soup 解析数据(感谢东哥) 有的小伙伴们对写正则表达式的写法用得不熟练,没关系,我们还有一个更强大的工具,叫Beautiful Soup,有了它我们可以很方便地提取出HT ...

  9. hash 散列表

    一个字符串的hash值: •现在我们希望找到一个hash函数,使得每一个字符串都能够映射到一个整数上 •比如hash[i]=(hash[i-1]*p+idx(s[i]))%mod •字符串:abc,b ...

  10. Sublime Text 套件介紹(四):Pretty JSON

    JSON,一個輕量級的資料交換語言,目前許多網站AJAX request的回應結果都是JSON格式   以下是一個標準的JSON格式   { "firstName": " ...