10812 - Beat the Spread!

#include <stdio.h>

int main()
   {
   long N,s,d,score1,score2;
   scanf("%ld", &N);
   for(long count=1;count<=N;count++)
      {
      scanf("%ld%ld", &s, &d);
      if(s < d)
      printf("impossible\n");
      else
        {
        score1 = (s+d)/2;
        score2 = s-score1;
        if((s+d)%2 == 0 && score1 >= 0 && score2 >= 0)
          printf("%ld %ld\n",score1,score2);
        else
          printf("impossible\n");
        }
      }
   }

Comments

Popular posts from this blog

371 - Ackermann Functions

Create many folder with one click