首页 > ACM题库 > HDU-杭电 > HDU 1194 Beat the Spread![解题报告] C++
2013
12-04

HDU 1194 Beat the Spread![解题报告] C++

Beat the Spread!

问题描述 :

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

地址:http://acm.hdu.edu.cn/showproblem.php?pid=1194

题意:赌球,用比分的和与比分的差的绝对值赌博。

mark:注意比分都是整数。

代码:

#include <stdio.h>

int main()
{
    int t,m,n;
    scanf("%d", &t);
    while(t-- && scanf("%d%d", &m, &n))
        if(m < n || (m+n) & 1) puts("impossible");
        else printf("%d %d\n", (m+n)/2, (m-n)/2);
    return 0;
}

  1. 果然是夕党,连名字都改成骂她的了。我就问问你从哪看出她是婊子?顺治明媒正娶的是皇后!还有,这文中的人不都长得差不多吗,还美N倍!别告诉我这就是所谓的素质,可笑!为一个不真实的故事这样做,可笑!

  2. 样例输出和程序输出不吻合,修改一下样例输出吧。我用的是VC编译器,会提示我的i和j变量重复定义