超水的一题,输入(x+y)和(x-y)  输出x,y,但是注意输出x,y都为非负整数(因为这个我还wa了两次。。唉~~)

Beat the Spread!
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 18154   Accepted: 8676

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

Source

Waterloo local 2005.02.05

 1 //oimonster
 2 #include<cstdio>
 3 #include<cstdlib>
 4 #include<iostream>
 5 using namespace std;
 6 int main(){
 7     int i,j,n,a,b,c,d;
 8     scanf("%d",&n);
 9     for(i=1;i<=n;i++){
10         scanf("%d%d",&a,&b);
11         c=(a+b)/2;
12         d=(a-b)/2;
13         if((c<0)||(d<0)||((a+b)%2!=0))printf("impossible\n");
14         else printf("%d %d\n",c,d);
15     }
16     return 0;
17 }

View Code

转载于:https://www.cnblogs.com/oimonster/p/4338617.html

POJ 2301 Beat the Spread!相关推荐

  1. 【POJ - 2301 】Beat the Spread! (简单数学)

    题干: Superbowl Sunday is nearly here. In order to pass the time waiting for the half-time commercials ...

  2. (精)【ACM刷题之路】POJ题目详细多角度分类及推荐题目

    POJ上的一些水题(可用来练手和增加自信) (poj3299,poj2159,poj2739,poj1083,poj2262,poj1503,poj3006,poj2255,poj3094) 初期: ...

  3. POJ刷题列表——正在进行

    转载自:http://blog.csdn.net/pyub153/article/details/50480333 初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心 ...

  4. POJ前面的题目算法思路【转】

    1000 A+B Problem 送分题 49% 2005-5-7 1001 Exponentiation 高精度 85% 2005-5-7 1002 487-3279 n/a 90% 2005-5- ...

  5. poj题目详细分类及算法推荐题目

    DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  1024   Calendar Game       简单题  ...

  6. ACM POJ 题目分类(完整整理版本)

    DP: 1011   NTA                 简单题  1013   Great Equipment     简单题  1024   Calendar Game       简单题   ...

  7. POJ ZOJ题目分类

    POJ,ZOJ题目分类(多篇整合版,分类很细致,全面) 标签: 题目分类POJ整理 2015-04-18 14:44 1672人阅读 评论(0) 收藏 举报 本文章已收录于: 分类: ACM资料(5) ...

  8. POJ,ZOJ题目分类(多篇整合版,分类很细致,全面)

    水题: 3299,2159,2739,1083,2262,1503,3006,2255,3094 初级: 一.基本算法:        (1)枚举 (1753,2965)       (2)贪心(13 ...

  9. POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)

    本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...

最新文章

  1. mysql分区和分表比较_MySQL分区和分表的区别与联系
  2. PIX配置手册三(nat)
  3. python第四篇:linux命令行总结 + 自动备份Python程序
  4. NodeJS(express)连接、封装操作MySQL
  5. Spark _06_补充部分算子【一】
  6. python正则表达式匹配模式屠夫之桥_Python 编程快速上手 第 7章 模式匹配与正则表达式...
  7. dubbo-admin构建报错
  8. struct file 结构体
  9. 【招聘】智联NLP算法工程师
  10. php pcntl实现多进程
  11. 程序员的自我修炼——新手如何学好编程
  12. 实现高效的英文单词前缀匹配
  13. 关于自我的剖析 —— 认知(面试:你的缺点是什么)
  14. 致敬达叔!Python带你回顾达叔出演过的作品与合作过的演员
  15. 基于人体骨架检测的安全警戒线
  16. 使用SimpleUpdater实现WinForm自动升级
  17. 服务器端口分配导致job重启
  18. 学计算机的一定要看啊(各种计算机学习视频)
  19. 博客保存大数据SQL相关
  20. 保障企业总部与各分支机构之间数据传输的安全性------实验案例解析

热门文章

  1. Scala分支控制 if-else 注意事项
  2. 使用JJWT实现JWT代码示例
  3. Spring Boot 2.X 使用@Cacheable时注意事项
  4. Spring的使用步骤
  5. PowerDesigner的下载及安装
  6. 关于C++ Qt项目实现最简单Http Server的踩坑记录
  7. 关于定点机中的比例因子
  8. 5.3.3 计算机网络传输层之TCP拥塞控制(慢开始与拥塞避免、快重传和快恢复)
  9. 2.1.4 进程之间的通信(共享通信、消息传递、管道通信)
  10. java商城开发_javaweb实战之商城项目开发(一)