zoj 2388 Beat the Spread!
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!的更多相关文章
- Beat the Spread![HDU1194]
Beat the Spread! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 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. ...
- 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) ...
- 转载 ACM训练计划
leetcode代码 利用堆栈:http://oj.leetcode.com/problems/evaluate-reverse-polish-notation/http://oj.leetcode. ...
- ACM学习
转:ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. US ...
- (转载)ACM训练计划,先过一遍基础再按此拼搏吧!!!!
ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. USACO ht ...
随机推荐
- 【C#】.net 导出Excel功能
将DataSet对象导出成Excel文档 一.不带格式控制 void btnExport_Click(object sender, EventArgs e) { IList<string> ...
- 回顾Quick Sort(Javascript 实现)
Introduction QuickSort的时间复杂度渐近函数虽然不能达到MergeSort般的O(nlgn),但因其良好的时间常量以及平均运行时间而被广泛使用. 下图解释了QuickSort的过程 ...
- jQuery事件,对象以及插件
回顾 1 基本使用 2 jquery 选择器 3 筛选器 过滤 查找 串联 4 DOM 操作 内部插入 append()appendTo()prepend()prependTo() 外部插入 afte ...
- Smack+OpenFire搭建IM通信,包含心跳和自动重连(Android实现)
Smack是一个开源,易于使用的XMPP(jabber)客户端类库.优点:简单的,功能强大,给用户发送信息只需三行代码便可完成.缺点:API并非为大量并发用户设计,每个客户要1个线程,占用资源大.Op ...
- Bootstrap 入门到精通
介绍 Bootstrap,来自 Twitter,是目前最受欢迎的前端框架.Bootstrap 是基于 HTML.CSS.JAVASCRIPT 的,它简洁灵活,使得 Web 开发更加快捷.Bootstr ...
- vba 两个表 信息合体一个表格
1 把Excel某一区域的内容读入到数组中: Dim strArray() As Variant Dim wk_data As Variant Set wk_data = Sheets("S ...
- div+css实现几种经典布局的详解
一.左右两侧,左侧固定宽度200px,右侧自适应占满 <div class="divBox"> <div class="left">&l ...
- LVM逻辑分区的优缺点与步骤
一.LVM简介 1. 什么是LVM? LVM是 Logical Volume Manager(逻辑卷管理)的简写 2. 为什么使用LVM? LVM通常用于装备大量磁盘的系统,但它同样适于仅有一.两块硬 ...
- WPF知识点全攻略08- 依赖属性
依赖属性是WPF不得不提,不得不会系列又一 先来看一下,自定义依赖属性的写法 public static readonly DependencyProperty IconProperty = Depe ...
- 使用bat脚本调用py文件直接获取应用的包名和targetversion
背景: 在上一篇已经介绍过如何利用python调用aapt获取包名 https://www.cnblogs.com/reseelei-despair/p/11078750.html 但是因为每次都要修 ...