二元一次方程

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1753 給你這2個值,你能推出這2隊最後的得分是多少嗎?

 

 

 

Input

輸入的第一列有一個整數,代表以下有多少組測試資料。

每組測試資料一列,有2個大於等於 0 的整數 s, d,s 代表比賽結束時2隊分數的總和, d 代表比賽結束時2隊分數差的絕對值。

Output

對每組測試資料輸出一列,包含2個整數代表比賽結束時這2隊的分數,分數大的在前。如果沒有這樣的分數,請輸出「 impossible」。

請記得:美式足球的分數一定是大於等於 0 的整數。

#include<stdio.h>

int main(){

    int t,a,b,c,d;

    scanf("%d",&t);

    while(t--){

    scanf("%d%d",&a,&b);

        if((a<b)||((a+b)%2!=0))printf("impossible\n");

    else {

    c=(a+b)/2;  二元一次不等式 

      d=(a-b)/2; 

        printf("%d %d\n",c,d);             

}

}    

return 0;    

}

posted @ 2013-02-28 18:44  L kill  阅读(188)  评论(0编辑  收藏  举报