Prime Palindrome wrong answer

http://www.codechef.com/status/PRPALIN

this is the link to my code…On my system it gives correct output for every input…I don’t know against what input is it being tested…please help me…Otherwise give me some input cases or else check that yourself…but please do point out the mistakes…

There are many mistakes in your code which have to be corrected.

1)BE CAREFUL WITH WHAT YOU OUTPUT.

your code does not output what the problem asks you to output. ie) given n ,your output must be the smallest prime palindrome>=n.for ex if the input is 1000000 then output must be 1003001.but this is not what your code outputs.it outputs the foll:

OUTPUT:

1000000

1000001

1001001

1002001

1003001 1003001

i corrected the error.but still your code shows wa for the foll inputs:

input:
2

your output:
11
correct o/p:
2

input:
101

your o/p:
131

correct o/p:
101

So,as far my observation,your code gives wrong answer for all nos from 1 to 10.and for nos greater than 10,it gives wrong answer if the i/p no itself is a prime palindrome as in the case of 101 ie)it checks for the smallest prime palindrome >n,but it should check for smallest prime palindrome >=n.
i think the mistake lies in the palindrome generation part,check for error in that part.HAPPY CODING :slight_smile:

1 Like

here is the link to your corrected and accepted solution: http://www.codechef.com/viewsolution/4372896 . if you find my post helpful ,upvote and mark it as accepted answer.HAPPY CODING:)