There does not look any error.
So we can only guess.
Wow, how can you say that the brackets donāt make an answer wrong. There are multiple cases when because of the brackets, the answer received is different from than what was expected.
And I am not just making a random guess but an educated guess looking at the results.
I can only confirm once the problem is moved to practice and I can make some manipulations and submit his program.
but in that particular code all brackets are correctā¦ i didnt said that in generalā¦
This seems the most likely explanation to me.
But the guess is wrong. I submitted the same way and got AC
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin >> t;
while(t--) {
long long a, b;
cin >> a >> b;
if(a % (b + 1) == 0) {
cout << "B" << endl;
}
else {
cout << "A" << endl;
}
}
return 0;
}
Do you by any chance mean just because he put the bracket around n, a wrong answer came?
No; this bit in his code:
if(n<=k)
{
cout<<"A\n";
}
would make the answer come out as A
for N=0, whereas yours would be B
. @sunil5798ās hypothesis is that the constraints are wrong, and that one of the testcases has N=0. I also think this is the most plausible scenario.
i dont like when such thing happensā¦ author should carefully make test casesā¦ i am depressed that my team wasnāt able to solve this problem due to this issueā¦
Yup, but according to the problem it should be A only(I guess, because he starts with 0). But yes, you have given me a possibility of why his answer can be wrong. Even though I didnāt understand how
Well, we might be wrong and the testcases might be fine, but this is the only thing I can think of that would cause the OPās code to give the wrong answer.
@ssjgz thanks for your timeā¦but only one question remains in my mindā¦ how to deal with such problems when my code is correct but still WA appearsā¦ how to tackleā¦ take this problem as exampleā¦
This seems like the most plausible scenario. If you have a look at this code
https://www.codechef.com/viewsolution/30001819
You can see that it is the exact same solution, the only difference is that here there is an extra condition in the beginning
if(n==0) cout<<"B\n";
And this yields an AC.
wow, you checked all the codes?
Same problem with my code.
As this is constraints issue, Will @admin reconsider the submissions?
for _ in range(int(input())):
n,m=map(int,input().split())
if n<=m:
print("A")
elif n%(m+1)==0:
print("B")
else:
print("A")
@anon44231457 @sunil5798 @hblord787 , @ssjgz is right. Actually one of our test case file contains n=0, which is producing contradicting answers. We forgot to take this scenario into account while generating our test case file. We are really sorry for this blunder and inconvenience caused by it , hope you understand.
So the fault was in test case!
@anon44231457 , @hblord787, @rohit_iiitl : we wasted 3 hours on this wowā¦ that was a nice blunder. special thanks to @mittal_sahab