Page 2 of 3

### Re: 10812 - Beat the Spread!

Posted: Fri Dec 26, 2008 11:24 pm
i got AC.

### Beat the spread -getting WA

Posted: Tue Aug 25, 2009 7:47 pm
can any1 help me with what is wrong about my code.here is my code-
#include<stdio.h>

int main()

{
int i,x,s,d,sum,min;

while(scanf("%d",&x)==1)

{
for(i=0;i<x;i++)
{
scanf("%d",&s);
scanf("%d",&d);

sum=(s+d);
min=(s-d);

if(s>d || s==d ) {

if((sum%2==0) && (min%2==0))

{

printf("%d\n",(s+d)/2);
printf("%d\n",(s-d)/2);
}

else printf("impossible\n");
}
else if(s<d) printf("impossible\n");}

}
return 0;
}

Posted: Fri Sep 11, 2009 1:02 am
can any1 help me please ,with what is wrong about my code.here is my code-
#include<stdio.h>

int main()

{
int i,x,s,d,sum,min;

while(scanf("%d",&x)==1)

{
for(i=0;i<x;i++)
{
scanf("%d",&s);
scanf("%d",&d);

sum=(s+d);
min=(s-d);

if(s>d || s==d ) {

if((sum%2==0) && (min%2==0))

{

printf("%d\n",(s+d)/2);
printf("%d\n",(s-d)/2);
}

else printf("impossible\n");
}
else if(s<d) printf("impossible\n");}

}
return 0;
}

### Re: 10812 - Beat the Spread!

Posted: Sat Oct 10, 2009 4:02 pm
i need help.i just cant understand!!!!!

#include<stdio.h>

long x,y,s,d,n,i,a,b;

{
scanf("%ld%ld",&s,&d);
if(s>=d)
{
x=(s+d);
y=(s-d);
a=x/2;
b=y/2;
if((x%2==0) && (y%2==0) && (a>0) && (b>0))
printf("%ld %ld",a,b);
else
printf("impossible");
}
else
printf("impossible");
printf("\n");
a=b=x=y=0;
}

int main(void)
{
while(scanf("%ld",&n)==1)
{
for( i = 1 ; i <= n ; i ++)
{
}
}
return 0;
}

### Re: 10812 - Beat the Spread!

Posted: Sun Oct 11, 2009 10:49 am
I got it!!!!! i think more about this easy problem. The addition of two number is always even.so why should i check it?

### Re: Beat the spread -getting WA

Posted: Thu Dec 09, 2010 10:31 pm
You're printing the two numbers on separate lines. They should be on the same line. See the problem's output sample. I don't think there is any other fault.

### Re: 10812 - Beat the Spread!

Posted: Fri Feb 04, 2011 6:13 pm
can any one say why um getting WA ?

Code: Select all

``````#include<stdio.h>
int main(){
long a,b,tst;
scanf("%d",&tst);
while(tst--){
int s,d;
scanf("%d %d",&a,&b);
s=a+b;d=a-b;
if((a+b)%2)printf("impossible\n");
else if((a-b)%2)printf("impossible\n");
else if(a<b)printf("impossible\n");
else printf("%d %d\n",s/2,d/2);
}
return 0;
}
``````

### Re: 10812 - Beat the Spread!

Posted: Tue Feb 15, 2011 6:55 pm
#include<stdio.h>
int main()
{
long int t, s, d, a, c;
scanf("%d",&t);
while(t--)
{
scanf("%d %d", &s, &d);
a = (s - d) / 2;
if((s%2==0 && d%2!=0) || (s%2!=0 && d%2==0) || (s-d)<0) printf("impossible\n");
else
{ if(a < s-a){ c = a; a = s - a; }
printf("%d %d\n", a, c);
}
}

return 0;
}

This is my code I got WA . Please anybody help me.

### Re: 10812 - Beat the Spread!

Posted: Fri Sep 09, 2011 3:50 pm
i m getting w.a..... here is my code #include<stdio.h>
//#include<iostream.h>
int main()
{
int t,s,d,i,j;
scanf("%d",&t);
while(t>0)
{
scanf("%d%d",&s,&d);
if(s<d)
{
printf("impossible\n");
goto m;
}
for(i=d;i<=s;i++)
{
for(j=0;j<=d;j++)
{
if(i+j==s && i-j==d)
{
goto l;
}
}
}
printf("impossible\n");
goto m;
l: printf("%d %d\n",i,j);
m: t--;
}
// system("pause");
return 0;
}

### Re: 10812 - Beat the Spread!

Posted: Sat Jun 30, 2012 10:06 pm
Much easy problem. This samples might help.
Input:

Code: Select all

``````12
15 10
88 9
155 22
20 10
40 12
75 25
13 7
888 222
9999 1111
12365 123
99 11
13 19``````
Output:

Code: Select all

``````impossible
impossible
impossible
15 5
26 14
50 25
10 3
555 333
5555 4444
6244 6121
55 44
impossible
``````

### Re: 10812 - Beat the Spread!

Posted: Fri Jul 27, 2012 1:56 pm
Can Anyone help me finding problem at this code? I got wrong answer every time . Help me please

#include <stdio.h>

int main()
{
long int n, s, d, difference, big, small;
int i, count=0;

scanf("%ld", &n);

for(i=0; i<n; ++i)
{
scanf("%ld %ld", &s, &d);

if(d>s)
{
printf("impossible");
}
else if(d==0 && s%2==0)
{
printf("%ld %ld\n", s/2, s/2);
}
else if(s%2==0 && d%2==1)
printf("impossible\n");
else if(d==0 && s%2==1)
printf("impossible\n");
else
{
difference=s-d;
if(difference%2==1)
{
printf("impossible\n");
continue;
}
big = difference/2 + d;
small = s - big;
printf("%ld %ld\n", big, small);
}
}
return 0;
}

### Re: 10812 - Beat the Spread!

Posted: Sat Jul 28, 2012 1:27 am
line 16 is missing a newline.

### Re: 10812 - Beat the Spread!

Posted: Sat Jul 28, 2012 2:29 am
Thanks Bro.       ### Re: 10812 - Beat the Spread!

Posted: Wed Jul 10, 2013 10:45 pm
#include<stdio.h>

int main()
{
int i,sum,t,a,b,dif;
scanf("%d",&t);
for(i=1;i<=t;i++){
scanf("%d %d",&sum,&dif);
if(dif<=0 ||(dif+sum)%2==1 || sum<=0 || dif>sum)
printf("impossible\n");
else {

a=(dif+sum)/2;
b=sum-a;
if(a>=0 && b>=0){
if(a>b)
printf("%d %d\n",a,b);
else{printf("%d %d\n",b,a);}}
}
}
return 0;
}

### Re: 10812 - Beat the Spread!

Posted: Thu Jul 11, 2013 11:36 pm
Input:

Code: Select all

``````1
0 0``````
Output should be:

Code: Select all

``````0 0
``````