Beat the Spread!


Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4683    Accepted Submission(s): 2441

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

题目大意:已知一场比赛两个终于得分的和,以及两个终于得分的绝对值差。

求两个终于得分。

若没有这种两个得分。则输出impossible。终于得分不能

为负

思路:英语理解题。最基本的是读懂题意。

两个最种得分的计算方法例如以下:

a = (s+d)/2。b = (s-d)/2。

若a、b都为整数。且都大于0,则满足条件,

否则输出impossible

#include<stdio.h>

int main()
{
int T,s,d;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&s,&d);
int a = -1;
int b = -1;
if((s+d)%2 == 0)
{
a = (s+d)/2;
b = (s-d)/2;
}
if(a>0 && b>0)
printf("%d %d\n",a,b);
else
printf("impossible\n");
} return 0;
}

HDU1194_Beat the Spread!的更多相关文章

  1. spread 程序调试时,未激活的提示解决

    场景:程序调试运行,打开含spread组件的窗体时如下: 解决: 将spread组件拖到某一个窗体后,会在properties中出现license文件.再运行,OK! 注意: license文件一定是 ...

  2. 《理解 ES6》阅读整理:函数(Functions)(三)Function Constructor & Spread Operator

    增强的Function构造函数(Increased Capabilities of the Function Constructor) 在Javascript中Function构造函数可以让你创建一个 ...

  3. spread表格树实现

    先上图看下效果图: 玩表格的朋友应该对Component和C1Flexgrid并不陌生吧.其实我也有用C1和DGV扩展了一个表格树,占有内存小,效率也可以,但是UI是硬伤,中规中矩,不美观.我上面是基 ...

  4. spread语法解析与使用

    @[spread, javavscript, es6, react] Spread语法是ES6中的一个新特性,在需要使用多参数(函数参数).多元素(数组迭代)或者多变量(解构赋值)的地方使用sprea ...

  5. Beat the Spread![HDU1194]

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

  6. C#打印页面的纸张设置问题Spread表格控件

    这段时间学习spread控件,用到打印设置上边,其他的设置都还好说,但是打印纸张的大小,纸张类型等把我折腾的够呛,找了半天才找到,记录下来备查. 1.打印纸张类型: System.Drawing.Pr ...

  7. [ES6] 13. Using the ES6 spread operator ...

    The spread operator (...) allows you to "explode" an array into its individual elements. S ...

  8. Spread 之自定义对角线cellType源码: DiagonalCellType

    最新的SpreadWinform提供了多达24种CellType类型,下面的这2篇博文对新增了GcTextBoxCellType和GcDateTimeCellType单元格格式做了比较详细的说明. & ...

  9. [ES6] 23. Rest Parameters & Spread Parameters

    Rest Parameters: In ES5, when you don't know how many paramters will be passed in, you can use argum ...

随机推荐

  1. open sql 更新数据

    insert语句: 1.插入单行数据有两种方法:wa是一个工作区 insert into dbtab values wa. insert into dbtab from wa. 该语句也可以将数据行插 ...

  2. 回文(manacher)

    裸manacher 我竟然写跪了………… 一个地方(偶数)没写清楚…… 我OOXOXOXOXXOXO #include<cstdio> #include<cstdlib> #i ...

  3. mysql update改动多条数据

    通常情况下,我们会使用下面SQL语句来更新字段值: 复制代码代码例如以下: UPDATE mytable SET myfield='value' WHERE other_field='other_va ...

  4. “ASP.default_aspx”并不包括“DropDownList1_SelectedIndexChanged”的定义,其解决方法。

    "ASP.default_aspx"并不包括"DropDownList1_SelectedIndexChanged"的定义,其解决方法. 在使用DropDown ...

  5. SilkTest高级进阶系列8 – 放下榔头,立地成佛

    在地球尚未毁灭的某天,手动测试的同事找到你所在的自动组,问是否可以帮助他们自动化一个需要连续添加100个条目的测试用例,因为他们觉得这是一个噩梦.你口头上说要先烟酒烟酒才能知道,但是内里早就满心欢喜: ...

  6. 关于索引删除的策略IndexDeletionPolicy

    关于索引删除的策略IndexDeletionPolicy . public IndexWriter(Directory d, Analyzer a, boolean create)          ...

  7. 编程算法 - 萨鲁曼的军队(Saruman&#39;s Army) 代码(C)

    萨鲁曼的军队(Saruman's Army) 代码(C) 本文地址: http://blog.csdn.net/caroline_wendy 题目: 直线上有N个点, 每个点, 其距离为R以内的区域里 ...

  8. Android开发周报:Flyme OS开源、经典开源项目解析

    Android开发周报:Flyme OS开源.经典开源项目解析 新闻 <魅族Flyme OS源码上线Github> :近日魅族正式发布了MX5,并且在发布会上,魅族还宣布Flyme OS开 ...

  9. OCA读书笔记(13) - 性能管理

    使用EM监控性能使用自动内存管理(AMM)使用Memory Advisor分配内存查看性能相关动态视图诊断无效的和不可用的对象 创建问题SQLsqlplus / as sysdbaconn scott ...

  10. 常见问题(FAQ) | VPNCUP

    常见问题(FAQ) | VPNCUP 常见问题(FAQ) 关于FAQ 新手开始 登录验证问题 为什么刚注册后,登录VPN服务器提示错误? 免费注册的用户有哪些限制? 为什么连接免费VPN后20分钟自动 ...