Skip to content

Instantly share code, notes, and snippets.

@henrybear327
Last active August 29, 2015 14:07
Show Gist options
  • Save henrybear327/cce5bce85acae431820a to your computer and use it in GitHub Desktop.
Save henrybear327/cce5bce85acae431820a to your computer and use it in GitHub Desktop.
ACM10812(using for).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);
for(count = 1; count <= total_cases; count++){
scanf("%d %d", &input_1, &input_2);
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