UVa 10812 - Beat the Spread!

  题目大意:知道一场橄榄球比赛比分的和以及差的绝对值,算出这两个数。注意判断结果的可能性(比分为非负数)。

 1 #include <cstdio>
 2 
 3 int main()
 4 {
 5 #ifdef LOCAL
 6     freopen("in", "r", stdin);
 7 #endif
 8     int n;
 9     scanf("%d", &n);
10     int s, d, a, b;
11     while (n--)
12     {
13         scanf("%d%d", &s, &d);
14         if (s < d || (s+d)%2)
15         {
16             printf("impossible\n");
17             continue;
18         }
19         a = (s+d) / 2;
20         b = s - a;
21         printf("%d %d\n", a, b);
22     }
23     return 0;
24 }
25         
View Code

 

posted @ 2013-08-28 20:22  xiaobaibuhei  阅读(184)  评论(0)    收藏  举报