若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1652: Beat the Spread!

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,338

题目描述

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?

输入

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.

输出

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.

样例输入

2
40 20
20 40

样例输出

30 10
impossible

参考代码

#include<stdio.h>
int main() 
{
    long n,a,b,x,y,s,flag;
    scanf("%ld",&n);
    while(n--) 
    {
        scanf("%ld%ld",&a,&b);
        flag=0;
        x=(a+b)/2;
        y=(a-b)/2;
        s=a+b;
        if(s%2!=0) printf("impossiblen");
  else if(x<0||y<0) printf("impossiblen");
  else printf("%ld %ldn",x,y);
           }
return 0;
      }

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

原站点 Skip Dreams孤独患者
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist