HDU1194_Beat the Spread!
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!的更多相关文章
- spread 程序调试时,未激活的提示解决
场景:程序调试运行,打开含spread组件的窗体时如下: 解决: 将spread组件拖到某一个窗体后,会在properties中出现license文件.再运行,OK! 注意: license文件一定是 ...
- 《理解 ES6》阅读整理:函数(Functions)(三)Function Constructor & Spread Operator
增强的Function构造函数(Increased Capabilities of the Function Constructor) 在Javascript中Function构造函数可以让你创建一个 ...
- spread表格树实现
先上图看下效果图: 玩表格的朋友应该对Component和C1Flexgrid并不陌生吧.其实我也有用C1和DGV扩展了一个表格树,占有内存小,效率也可以,但是UI是硬伤,中规中矩,不美观.我上面是基 ...
- spread语法解析与使用
@[spread, javavscript, es6, react] Spread语法是ES6中的一个新特性,在需要使用多参数(函数参数).多元素(数组迭代)或者多变量(解构赋值)的地方使用sprea ...
- Beat the Spread![HDU1194]
Beat the Spread! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- C#打印页面的纸张设置问题Spread表格控件
这段时间学习spread控件,用到打印设置上边,其他的设置都还好说,但是打印纸张的大小,纸张类型等把我折腾的够呛,找了半天才找到,记录下来备查. 1.打印纸张类型: System.Drawing.Pr ...
- [ES6] 13. Using the ES6 spread operator ...
The spread operator (...) allows you to "explode" an array into its individual elements. S ...
- Spread 之自定义对角线cellType源码: DiagonalCellType
最新的SpreadWinform提供了多达24种CellType类型,下面的这2篇博文对新增了GcTextBoxCellType和GcDateTimeCellType单元格格式做了比较详细的说明. & ...
- [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 ...
随机推荐
- 让工程师爱上CMM,实现管理于无形 --- 中标软件CMMI L5之路 (2/2)
上节:见 http://blog.csdn.net/sztiger168/article/details/9142069 使用 青铜器RDM在2011年正式在中标软件上线,将研发业务全面流程化,完全支 ...
- tomcat path设置
zjtest7-app:/usr/local/apache-tomcat-7.0.55_8082/logs# netstat -nap | grep 8082 tcp 0 0 :::8082 :::* ...
- Unable to instantiate activity ComponentInfo或java.lang.ClassNotFoundException: com.ibright.herolegen
不知道怎么回事,在libs中添加了jar包后,无法给jar包附加上源码,于是采取以下措施: 删除自动生成的依赖: 在Android Dependences目录上右击->Build Path -& ...
- QQ圈子降级为“应用”后应关注其隐私设置
在之前的QQ版本中,QQ圈子的权限设置在“系统设置”对话框的“权限设置”中,如图所示. 但是在更新后的2013SP1版本中,“系统设置”对话框中的“权限设置”已经没有了“圈子权限” QQ圈子成了应用管 ...
- Delphi引用C对象文件
C语言应用非常广泛,并在世界各地拥有大量的代码库.这些代码库与Delphi的可比性较小,因此如果我们无需转换为Delphi代码而可以直接使用这些库的部分代码就完美了.幸运的是,Delphi允许连接到C ...
- 01-编写CMS注意事项
原文:01-编写CMS注意事项 1.将ThinkPHP核心文件放在项目目录,将下载的扩展包放在在ThinkPHP目录下的Extend文件夹中 2.设置整个项目的编码为utf-8 3.创建Public公 ...
- gant
http://gant.github.io/ http://gant.codehaus.org/
- MySQL的Master/Slave群集安装和配置
本文介绍MySQL的Master/Slave群集安装和配置,版本号安装最新的稳定版GA 5.6.19. 为了支持有限HA.我们用Master/Slave读写简单孤立的集群.有限HA这是当Master不 ...
- [Cocos2d-x]节点的尺寸大小
作为一个CCNode,本身没有大小而言,但是AddChild之后,便有了尺寸的概念. Cocos2d-x中对于一个节点的尺寸可以通过以下三个方法获取: CCSprite: getContentSize ...
- Zigbee开发(1)
只是研究zigbee的技术,也许后续的博客不会有很及时的更新,有时间 写一点东西能让大家有所收获吧. 环境搭建 Windows 64位的操作系统 IAR7.6 for 8051 ZStack CC25 ...