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
10812 - Beat the Spread!
Moderator: Board moderators
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10812 - Beat the Spread!
There should be a space in between numbers in the output
Check input and AC output for thousands of problems on uDebug!
Re: 10812 - Beat the Spread!
Anybody please help me...
Why am I getting Runtime Error...
Why RE occur??
Why am I getting Runtime Error...
Why RE occur??
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10812 - Beat the Spread!
Check input and AC output for thousands of problems on uDebug!
Re: 10812 - Beat the Spread! why i get WA pls help me
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;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10812 - Beat the Spread!
brianfry713 wrote:Input:Output should be:Code: Select all
1 0 0
Code: Select all
0 0
Check input and AC output for thousands of problems on uDebug!