2011年7月12日 星期二

ACM 10812 Beat the Spread!

解方程式


#include <stdio.h>

int main(void)
{
    int x, y, s, d, t;
   
    scanf("%d", &t);
    while (t--)
    {
        scanf("%d%d", &s, &d);
        x = s+d;
        y = s-d;
        if (y >= 0 && x%2 == 0 && y%2 == 0)
            printf("%d %d\n", x/2, y/2);
        else
            printf("impossible\n");
    }

    return 0;
}

沒有留言:

張貼留言