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 ...
随机推荐
- must return an Iterable of arrays.(junit4)
java.lang.Exception: TestIterator.init() must return an Iterable of arrays. at org.junit.runners.Par ...
- 枚举算法总结 coming~^.*
感谢CJ同学监督╭(╯^╰)╮.从放假到现在都木有更新博客了~噶呜~小娘谨记教诲,每天会更新博客==!! 看了一下POJ训练计划,虽然已经零零散散做了40多道题了,还是从头开始整理一下漏掉的知识点.T ...
- uva 10581 - Partitioning for fun and profit(记忆化搜索+数论)
题目链接:uva 10581 - Partitioning for fun and profit 题目大意:给定m,n,k,将m分解成n份,然后依照每份的个数排定字典序,而且划分时要求ai−1≤ai, ...
- Delphi的类型转换 good
Delphi是一种强类型转换的语言.在VC中,赋值符用″=″,例如x=1;到了Delphi赋值符就变成了″:=″,例如x:=1. 从赋值时用符号″:=″而不用″=″,就隐约可见Delphi对类型匹配要 ...
- Jquery事件的连接
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 如何理解java回电话
同android中间Button的setOnClickListener这个回调案例: Button button = (Button)this.findViewById(R.id.button); b ...
- 检查java class的版本号
补丁总是会一遍又一遍的打,越打越多 有时候,就担心有人不小心把高版本的class打到低版本jre运行的环境中 简单写了点代码,检查文件夹中class的版本号 package org.wee.cv; i ...
- [Android学习笔记]Android调试
Eclipse Debug 快捷键: [Ctrl + Shift + B]: 添加/取消断点 [F5]:进入方法中 [F6]:单步执行 [F7]:执行完毕此方法 [F8]:继续执行,直接跳到下一个断点 ...
- Cocos2d-x 游戏存档
游戏存档功能能够保存游戏中数据.让玩家游戏能够延续. 单机游戏更为重要.而CCUserDefault能够作轻量级数据库使用,用来存储数据,支持数据类型bool,int, float, double, ...
- GitLab 5.3 升级注意事项
最主要就是需要更新的Git.我的Ubuntu12.04通过apt-get install安装的git版本过低. 所以只能通过源代码安装. 参考下面的步骤: wget git-core.googleco ...