Sort 16 Discussions, By:
Please Login in order to post a comment
all the prime numbers which contains 0/2/4/6/8/5 can't make a circular prime number because last digit with those number is not the prime number(divisible by 2 or 5) so sieve skill will have a powerful effect on reducing domain again...
Had timeout on last testcase until used an idea from your comment. Thanks!
Thanks for this Comment. Passed the last TC with your help.
One issue here is that it is not specified whether a prime which is circluar and \leq N is still defined to be circluar if its rotations happen to exceed N. Perhaps this distinction should be clarified.
Okay added it if this wasn't clear.
Make sure you're testing ROTATIONS of the digits instead of permutations. I made that mistake.
Can somebody(staff members) please give me a hint why I am getting WA.I think my logic is correct.Is there a problem with exceeding the value of data type?
I also got it wrong first, note that these are not permutable, but circular primes. http://primes.utm.edu/glossary/xpage/CircularPrime.html
All circular primes less than 10^6 can be found and sorted in under 0.5 seconds using Python 3. Here are some tips.
if x in y
can anyone help me..its showing timeout for last case ..
if n==2: return 
elif n<2: return 
mroot = n ** 0.5
while m <= mroot:
return +[x for x in s if x]
for z in c:
for i in range(1,k+1):
if int(new) not in c:
You shouldn't run in more than 6s in python without headaches.
First compute all primes below N
Then for each, play with strings for each rotation and sum primes that are circular.
And voilà, all TC cleared
test case 5...timeout ??
Simple sieve and this can make you submission run in 0.3s for last test case.
No further optimization required.
Can sum1 help me in improvise my code..
getting timeout error for testcase 4 and 5..
thanks in advance..