Problem Description Link
Algorithm:
This is a simple problem but need more time than other problem.
you can follow this technique .
1. Firstly you need to generate prime in prime[] array up to max=20000000 before getting input.
2. Then you need to set th' prime in thprime[] array up to 100000-th+ something
process:
k=0;
for i=1 to i=(max/13)*12;
if(prime[i] && prime[i+2] )
thprime[k++]=i;
N.B: i=(max/13)*12 because 100000-th prime in (max/13)*12 range no need extra calculation.
3. now get the input (say n) and
4. print thprime[n] and thprime[n]+2;
Algorithm:
This is a simple problem but need more time than other problem.
you can follow this technique .
1. Firstly you need to generate prime in prime[] array up to max=20000000 before getting input.
2. Then you need to set th' prime in thprime[] array up to 100000-th+ something
process:
k=0;
for i=1 to i=(max/13)*12;
if(prime[i] && prime[i+2] )
thprime[k++]=i;
N.B: i=(max/13)*12 because 100000-th prime in (max/13)*12 range no need extra calculation.
3. now get the input (say n) and
4. print thprime[n] and thprime[n]+2;
No comments:
Post a Comment
Write your comment - Share Knowledge and Experience