The code is always wrong, I accept it exceeds time limit for second task, but it’s telling the answer wrong even for the subtask. Can anyone please help me out to figure out what’s wrong in this code.
Even after changing the code multiple times and testing with different inputs still i get wrong answer. But it works find locally for a bunch of inputs i tried. Could anyone check and let me know whats wrong here ?
Please tell me bout the error. Its a program to find the reverse n of the number. #include
using namespace std;
int main()
{
int t;
cin>>t;
if((t>=1)&&(t<=1000))
{
for(int i=0; i<t; i++)
{
int num,rnum=0;
cin>>num;
if((num>=1)&&(num<=100000))
{
while(num!=0)
{
int b=num%10;
num=num/10;
rnum=rnum*10+b;
}
cout<<rnum<<endl;
}
}
}
}
This change really shouldn’t make any difference - can you give a testcase where it does?
I can’t see anything wrong with @sarthak1308’s solution at all, provided that the constraints are correct, which they often aren’t.
@sarthak1308 - try removing the if((t>=1)&&(t<=1000)) and if((num>=1)&&(num<=100000)) checks (they are not needed anyway). Then submit, and post a link to your submission here.
Lead game problem
Can you help me out here with whats wrong…Wrong answer error #include
using namespace std;
int main()
{
int T;
int alead=0,blead=0;
cin>>T;
if (T<=1000)
{
for (int i=0; i<T; i++)
{
int ascore,bscore;
cin>>ascore>>bscore;
if (ascore>bscore)
{
if((ascore-bscore)>alead)
alead=ascore-bscore;
}
else if (bscore>ascore)
{
if((bscore-ascore)>blead)
blead=bscore-ascore;
}
}
if(alead>blead)
cout<<1<<" “<<alead;
else if(blead>alead)
cout<<2<<” "<<blead;
}
}