Problem: https://mirror.codeforces.com/contest/1362/problem/A
My Submission: https://mirror.codeforces.com/contest/1362/submission/82595064
Test Case which it fails on: 7 576460752303423481
Correct Answer: -1
Answer when you run it locally:-1
Answer by Codeforces System:1
You can check the test case details of my submission.
Why Codeforces gives WA on this code?
I ran the code on CLion
by JetBrains.
Also I ran it on Codeforces Custom Invocation:
It gave -1
as expected, but while testing my code idk why it gave WA.
If you try the first 8 tests together on Custom Invocation, you will get the same wrong answer.
So, I thought the problem is in using
puts
while using synchronized input/output (fio
). And yes, that was the problem.In general, don't use C++ input/output with C input/output. Either use scanf/printf/puts or cin/cout with/without synchronization.