Beat the Spread![HDU1194]
Beat the Spread!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3482 Accepted Submission(s): 1821
Problem 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
University of Waterloo Local Contest 2005.02.05
Recommend
Ignatius.L
#include<stdio.h>
int main()
{
int T;
scanf("%d",&T);
while (T--)
{
int u,v;
scanf("%d%d",&u,&v);
if (u<v || (u+v)&1) printf("impossible\n");
else printf("%d %d\n",(u+v)/2,(u-v)/2);
}
return 0;
}
Beat the Spread![HDU1194]的更多相关文章
- 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. ...
- zoj 2388 Beat the Spread!
Beat the Spread! Time Limit: 2 Seconds Memory Limit: 65536 KB Superbowl Sunday is nearly here. ...
- HDOJ 1194 Beat the Spread!(简单题)
Problem Description Superbowl Sunday is nearly here. In order to pass the time waiting for the half- ...
- HDU 1194 - Beat the Spread!
给两数之和和两数之差,求两数,两数还必须同奇偶 #include <iostream> using namespace std; int main() { int a,b,t; cin&g ...
- UVa 10812 - Beat the Spread!
题目大意:知道一场橄榄球比赛比分的和以及差的绝对值,算出这两个数.注意判断结果的可能性(比分为非负数). #include <cstdio> int main() { #ifdef LOC ...
- HDU1194_Beat the Spread!
Beat the Spread! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- POJ 题目分类(转载)
Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- (转)POJ题目分类
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
随机推荐
- [Effective JavaScript 笔记]第47条:绝不要在Object.prototype中增加可枚举的属性
之前的几条都不断地重复着for...in循环,它便利好用,但又容易被原型污染.for...in循环最常见的用法是枚举字典中的元素.这里就是从侧面提出不要在共享的Object.prototype中增加可 ...
- Autolayout及VFL经验分享
http://www.cocoachina.com/industry/20131108/7322.html 这篇不是什么教程.Cocoa autolayout出来蛮久了.以前多次想去深入研究一下,每次 ...
- Bellman-Ford算法
#include<stdio.h> #define max 0xffffff ][]; //图的邻接矩阵 ]; int n;//顶点个数 int m;//边个数 struct Edge { ...
- [ruby on rails] 跟我学之(3)基于rails console的查增删改操作
本章节展开对model的介绍:包括查增删改操作.紧接着上面一节<[ruby on rails] 跟我学之HelloWorld> 创建模型 使用命令创建模型 创建表post,默认自带两栏位 ...
- web页面版权部分的显示问题
网站开发中绝大部分页面底部都需要版权信息,一般都是Copyright ©域名 2014 - 2015. All Rights Reserved.这种格式,当然也有其他的,有时候不太注意会发现做出的这个 ...
- php抽象类的简单应用
抽象类也是面向对象中的重要概念,和接口.继承的概念重要性相当,在面向对象的开发中,所有的对象都是通过类来描述的,但是反过来,并不是所有类都是用来描绘对象的,广义上讲如果一个类中没有足够信息来描述一个具 ...
- PHP--TP框架----生成验证码的方式
TP框架----生成验证码的方式 xianshi.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN& ...
- NEFU 1146 又见A+B
又见a+b Problem:1146 Time Limit:1000ms Memory Limit:65535K Description 给定两个非负整数A,B,求他们的和. Input 多组输入,每 ...
- Linux UGO
U=USER G=GROUP O=OTHERS 最前面的’-’,表示文件为普通类型 第一组的‘rw-’,表示文件属主对文件具有读和写权限,但没有执行权限 第二组的’rw-’,表示同组其他用户对文件具有 ...
- javascript首尾反转字符
var my_str="Welcome to www.sharejs.com" var i=my_str.length; i=i-1; for (var x = i; x > ...