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. 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>
#include<queue>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<cstring>
using namespace std;
#define LL long long int main()
{
int a,b,T;
scanf("%d",&T);
while(T--)
{scanf("%d%d",&a,&b);
if((a+b)%2==1){
printf("impossible\n");
continue;
}
int x=(a+b)/2;
int y=a-x;
if(x<y)
swap(x,y);
if(x>=0&&y>=0)
printf("%d %d\n",x,y);
else
printf("impossible\n");
}
return 0;
}
ZOJ2388 Beat the Spread! 2017-04-16 19:18 91人阅读 评论(0) 收藏的更多相关文章
- 团体程序设计天梯赛L2-009 抢红包 2017-03-22 19:18 131人阅读 评论(0) 收藏
L2-009. 抢红包 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 没有人没抢过红包吧-- 这里给出N个人之间互相发红包.抢 ...
- Matlab调用C程序 分类: Matlab c/c++ 2015-01-06 19:18 464人阅读 评论(0) 收藏
Matlab是矩阵语言,如果运算可以用矩阵实现,其运算速度非常快.但若运算中涉及到大量循环,Matlab的速度令人难以忍受的.当必须使用for循环且找不到对应的矩阵运算来等效时,可以将耗时长的函数用C ...
- 滑雪 分类: POJ 2015-07-23 19:48 9人阅读 评论(0) 收藏
滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 83276 Accepted: 31159 Description Mich ...
- HDU6029 Happy Necklace 2017-05-07 19:11 45人阅读 评论(0) 收藏
Happy Necklace Time Limit: ...
- HDU6027 Easy Summation 2017-05-07 19:02 23人阅读 评论(0) 收藏
Easy Summation Time Limit: 2000/1000 MS ...
- The Pilots Brothers' refrigerator 分类: POJ 2015-06-15 19:34 12人阅读 评论(0) 收藏
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20304 ...
- IP Address 分类: POJ 2015-06-12 19:34 12人阅读 评论(0) 收藏
IP Address Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 19125 Accepted: 11053 Desc ...
- HDU6026 Deleting Edges 2017-05-07 19:30 38人阅读 评论(0) 收藏
Deleting Edges Time ...
- ZOJ2256 Mincost 2017-04-16 19:36 44人阅读 评论(0) 收藏
Mincost Time Limit: 2 Seconds Memory Limit: 65536 KB The cost of taking a taxi in Hangzhou is n ...
随机推荐
- 代码规范 for node.js with 'npm-coding-style'
npm-coding-style npm's "funny" coding style Description npm's coding style is a bit unconv ...
- 使用SharpZip压缩与解压缩
使用SharpZip压缩与解压缩 编写人:左丘文 2015-4-11 大家在做项目时,相信会经常性的会遇到要对数据流或dataset byte[] 或文件进行压缩和解压缩,比如:利用webservic ...
- zeromq测试
debian sudo apt-get install libzmq3-dev pip install zmq client.py #coding: utf-8 import zmq context ...
- 【转】Java transient关键字使用小记
哎,虽然自己最熟的是Java,但很多Java基础知识都不知道,比如transient关键字以前都没用到过,所以不知道它的作用是什么,今天做笔试题时发现有一题是关于这个的,于是花个时间整理下transi ...
- 0001_mysql 5.7.25安装初始化
一. 下载mysql https://dev.mysql.com/downloads/mysql/ 二. 选择社区版本 三. 选择版本下载: 四. 跳过注册直接下载: 五. 解压后 ...
- NP、NPC、NP-hard问题的定义
NP-hard问题 定义:NP-hard问题是这样的问题,只要其中某个问题可以在P时间内解决,那么所有的NP问题就都可以在P时间内解决了.NP-c问题就是NP-hard问题.但注意NP-hard ...
- jdbc练习demo
//连接云端服务器数据库工具类 public class TestJDBCUtil { public static String driver="com.mysql.jdbc.Driver& ...
- 「小程序JAVA实战」小程序视频处理工具ffmpeg(47)
转自:https://idig8.com/2018/09/16/xiaochengxujavashizhanxiaochengxushipinchuligongjuffmpeg46/ 前面已经把视频成 ...
- FoxPro 数据库文件及记录命令
ADDTABLE 在当前数据库中添加一个自由表 APPEND 在表的末尾添加一个或多个新记录 APPEND FROM ARRAY 由数组添加记录到表中 APPEND FROM 从一个文件中读入记录,追 ...
- 最值得学习阅读的10个C语言开源项目代码
阅读优秀代码是提高开发人员修为的一种捷径-- 1. Webbench Webbench是一个在linux下使用的非常简单的网站压测工具.它使用fork()模拟多个客户端同时访问我们设定的URL,测试网 ...