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 ...
随机推荐
- Web验证方式(4)--JWT
OAuth协议中说到的AccessToken可以是以下两种: 1.任意只起到标识作用的字符串:这种情况下Resource Server处理请求时需要去找Authorization Server获取用户 ...
- C# 转义字符 '\'反斜杠
在代码中经常用到表示路径的字符串,如何正确转换反斜杠? 如要将"C:\123"转换成"C:\\123" 如何转换? 方法: string str="C ...
- 【详解】Linux的文件描述符fd与文件指针FILE*互相转换
使用系统调用的时候用文件描述符(file descriptor,简称fd)的时候比较多,但是操作比较原始.C库函数在I/O上提供了一些方便的包装(比如格式化I/O.重定向),但是对细节的控制不够. 如 ...
- C#计数器
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- ThinkPHP实现事务回滚示例代码
ThinkPHP的事务回滚示例如下: ? 1 2 3 4 5 6 7 8 9 10 $m=D('YourModel');//或者是M(); $m2=D('YouModel2'); $m->sta ...
- django-url命名空间+反查
from django.conf.urls import url, include urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^h ...
- c# 后台调用接口接收传过来的json
public string GetRequestTest(string url) { HttpWebRequest httpWebRequest = (HttpWebRequest)WebReques ...
- Maven(五)使用Nexus搭建Maven私服
文章装载于:http://blog.csdn.net/jun55xiu/article/details/39497089 Nexus介绍 Nexus是Maven仓库管理器,如果你使用Maven,你可以 ...
- Apache Flume 安装文档、日志收集
简介: 官网 http://flume.apache.org 文档 https://flume.apache.org/FlumeUserGuide.html hadoop 生态系统中,flume 的职 ...
- VMware Workstation 虚拟机的服务启动项