10812 - Beat the Spread!

All about problems in Volume 108. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

k23456
New poster
Posts: 1
Joined: Thu Sep 19, 2013 11:38 am

Re: 10812 - Beat the Spread!

Post by k23456 » Fri Sep 20, 2013 8:44 pm

guys i need help i dnt have any idea what's wrong with my code it works perfectly
#include <iostream>
using namespace std;

int main(){
long int a,b,t;
cin>>t;
while(t--){
cin>>a>>b;
long int s=(a+b)/2,m=(a-b)/2;
if(s>0 && m>0){
cout<<s<<m<<endl;}
else
cout<<"impossible"<<endl;

}
}

after submitting the code they keep on showing that the ans is wrong

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10812 - Beat the Spread!

Post by brianfry713 » Fri Sep 20, 2013 9:59 pm

There should be a space in between numbers in the output
Check input and AC output for thousands of problems on uDebug!

c000p
New poster
Posts: 1
Joined: Tue Oct 15, 2013 10:18 pm

Re: 10812 - Beat the Spread!

Post by c000p » Tue Oct 15, 2013 10:28 pm

Anybody please help me...
Why am I getting Runtime Error...
Why RE occur??

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10812 - Beat the Spread!

Post by brianfry713 » Wed Oct 16, 2013 8:25 pm

Check input and AC output for thousands of problems on uDebug!

cse dipto
New poster
Posts: 22
Joined: Tue Oct 29, 2013 6:46 pm

Re: 10812 - Beat the Spread! why i get WA pls help me

Post by cse dipto » Sat Jan 04, 2014 10:09 am

Code: Select all

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <stack>
#include <queue>
#include <map>
#include <vector>


using namespace std;

int main()
{
    long long int i,j,k,t_case,a,b,r,r1,R,R1;
    cin>>t_case;
    for(i=1;i<=t_case;i++)
    {
        cin>>a>>b;
        if(b>a)
        {
            printf("impossible\n");
        }
        else if(a>b)
        {
            r=a+b;
            r1=r/2;
            j=a-b;
            k=j/2;
            
            if((r1*2)==r&&(k*2)==j)
            {
                R=((a+b)/2);
                R1=((a-b)/2);
                printf("%lld %lld\n",R,R1);
            }
            else
            {
                printf("impossible\n");
            }
        }
    }
    return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10812 - Beat the Spread!

Post by brianfry713 » Wed Jan 15, 2014 12:39 am

brianfry713 wrote:Input:

Code: Select all

1
0 0
Output should be:

Code: Select all

0 0
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 108 (10800-10899)”