Can you please give me your submission link or your code so I can see what is wrong.
@sarthak1308 Your Code:
#include<iostream>
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;
}
}
}
}
How is it affecting the logic…?
i got your point, it should be that way (more professional but logic…?)
Still it is throwing wrong output…
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.
@vijju123 / @admin - can we get the constraints/ testcases fixed for this Problem?
Thanks to @aryan12 for confirming
Gotcha! You have to remove the Constraints part.
Here my solution:
#include<iostream>
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;
while(num>=10)
{
int b=num%10;
rnum=rnum*10+b;
num=num/10;
}
rnum=rnum*10+num;
cout<<rnum<<endl;
}
}
}
I don’t know, but I have just removed these two lines and I have got AC
2 lines I have removed
if((t>=1)&&(t<=1000))
if((num>=1)&&(num<=100000))
Thank you so much…its working after i removed the constraints…
The test file have N \leq 10^6. I have modified the statement.
Great, thanks for the rapid fix
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;
}
}
Can you tell me whats wrong?
That’s not a correct link to your code
This gives the wrong answer for the testcase:
9
3 66
3 20
2 60
2 1
1 69
3 66
3 1
3 72
1 54
(the answer should be
2 388
)