HOJ 2100 Beat the Spread!

http://acm.hit.edu.cn/hoj/problem/view?id=2100

给两个非负数s和d

s为两数之和 d为两数之差的绝对值

求这两个数

#include
int main()
{
    unsigned int n, s, d, big, little;

    scanf("%u", &n);
    while (n--)
    {
        scanf("%u %u", &s, &d);
        big = ( s + d ) / 2;
        little = s - big;
        if(s < d)
        {
            printf("impossible\n");
            continue;
        }
        if( ( (s % 2 != 0) && (d % 2 != 0) ) || ( (s % 2 == 0) && (d % 2 == 0) ) )
            printf("%u %u\n",big,little);
        else
            printf("impossible\n");
    }

    return 0;
}


 

你可能感兴趣的:(HOJ)