# UVa 10812
### 題目連結:[UVa10812](http://domen111.github.io/UVa-Easy-Viewer/?10812)
### 題述:
超級盃又來了,為了打發中場休息時間,大家就來下注最後的結果會如何。大家下注的目標為兩隊最後的分數和,或者兩隊最後分數差的絕對值。
給你這 2 個值,你能推出這 2 隊最後的得分是多少嗎?
---
輸入的第一列有一個整數,代表以下有多少組測試資料。
每組測試資料一列,有 2 個大於等於 0 的整數 s , d , s 代表比賽結束時 2 隊分數的總和, d 代表比賽結束時2隊分數差的絕對值。
---
對每組測試資料輸出一列,包含2個整數代表比賽結束時這2隊的分數,分數大的在前。如果沒有這樣的分數,請輸出 `impossible`。
分數一定是大於等於 0 的整數。
### c++ code:
```cpp=
#include<bits/stdc++.h>
using namespace std;
int main () {
//------------------------------------------------
#ifdef local
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//------------------------------------------------
int a ;
int b ;
int n ;
int ab ;
int ba ;
cin >> n ;
while ( n != 0 ) {
cin >> a >> b ;
if ( ( a + b ) % 2 != 0 ) {
cout << "impossible" << endl ;
} else if ( a < b ) {
cout << "impossible" << endl ;
} else {
ab = ( a + b ) / 2 ;
ba = ( a - ab ) ;
if ( ab > ba ) {
cout << ab << " " << ba << endl ;
} else {
cout << ba << " " << ab << endl ;
}
}
n -= 1 ;
}
}
```
:::success
**``sample input``**
4
40 20
20 40
5 1
100 1
:::
:::success
**``sample output``**
30 10
impossible
3 2
impossible
:::
#### [返回首頁](https://hackmd.io/@fkleofk/APCS#10812)
###### tags: `APCS選修` `C++` `UVa`