You are viewing a single comment's thread. Return to all comments →
I still got TLE :,v
me too , i have find some "tutorials" in web;s author: Kristan but only earn 50 d , when n>100000000 , i use miller rebin but it still over time .
When testing for many primes in bulk, Miller Rabin is actually quite slow. A Sieve of Eratosthenes may be faster.
But before changing your code, find out which part is slow: the prime testing, or finding the S values.
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Project Euler #134: Prime pair connection
You are viewing a single comment's thread. Return to all comments →
I still got TLE :,v
me too , i have find some "tutorials" in web;s author: Kristan but only earn 50 d , when n>100000000 , i use miller rebin but it still over time .
When testing for many primes in bulk, Miller Rabin is actually quite slow. A Sieve of Eratosthenes may be faster.
But before changing your code, find out which part is slow: the prime testing, or finding the S values.