Problem Type : Ad hoc
#include<stdio.h>
int main()
{
long int sum,difference,x,y,n,i;
while(scanf("%ld",&n)==1)
{
for(i=1; i<=n; i++)
{
scanf("%ld %ld",&sum,&difference);
if(difference>sum||(sum-difference)%2!=0)
{
printf("impossible\n");
continue;
}
else
{
x=(sum+difference)/2;
y=x-difference;
printf("%ld %ld\n",x,y);
}
}
}
return 0;
}
#include<stdio.h>
int main()
{
long int sum,difference,x,y,n,i;
while(scanf("%ld",&n)==1)
{
for(i=1; i<=n; i++)
{
scanf("%ld %ld",&sum,&difference);
if(difference>sum||(sum-difference)%2!=0)
{
printf("impossible\n");
continue;
}
else
{
x=(sum+difference)/2;
y=x-difference;
printf("%ld %ld\n",x,y);
}
}
}
return 0;
}
No comments:
Post a Comment