Yesterday I was submitted the problem B in the contest time and it was pretest passed. But after finishing the contest it got the wrong answer on test 15. But its output is correct in my laptop compiler. then same code i submitted again then it got the wrong answer on test 37 though it gave correct output .again i submitted code removing space but it WA on test 2.In my own laptop, it is given correctly for all test. What's the wrong with me ??
My Submission :http://codeforces.me/submissions/Hredoy_Biswas
There is no problem in java compiler on Codeforces. You used BigInteger.isProbablePrime(int certainty) method with certainty=1 which is not-deterministic and returns whether a prime number is prime with probability p ~= (1-1/2^certainty). So this behaviour is expected that sometimes it may give the non-prime number to be prime and some other times non-prime.
Dang, 1/2 chance to fail on every case and he made it to 37? That's solid.
Actually its guaranteed to be at least (1-1/2^certainty). In the general case, it is much more.