Skip to content

Instantly share code, notes, and snippets.

@henrybear327
Last active August 29, 2015 14:07
Show Gist options
  • Save henrybear327/ffde04f55ec00c5432a7 to your computer and use it in GitHub Desktop.
Save henrybear327/ffde04f55ec00c5432a7 to your computer and use it in GitHub Desktop.
ACM10812.c
#include <stdio.h>
#include <stdlib.h>
/*
http://uva.onlinejudge.org/index.php?option=onlinejudge&Itemid=99999999&page=show_problem&category=&problem=1753&mosmsg=Submission+received+with+ID+14388286
*/
int main()
{
int total_cases, count = 0, input_1, input_2;
scanf("%d", &total_cases);
while(scanf("%d %d", &input_1, &input_2)!= EOF){
count++;
if(count > total_cases){
break;
}
if(input_1 < input_2 || (input_1 + input_2) % 2 != 0 || (input_1 - input_2) % 2 != 0){
printf("impossible\n");
continue;
}
printf("%d %d\n", (input_1 + input_2) / 2, (input_1 - input_2) / 2);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment