Prime numbers in prime numbers Time limit:1000ms Memory limit:65536k have questions? Dot here ^_^ Title Description If a prime number, it is also prime in prime numbers, which is called prime numbers in prime numbers. For example 3 is a 2nd prime number, so 3 is prime number, although 7 is a prime number, but 7 in 4th place, so 7 is not prime numbers in the prime to give you a count of N, to find out the >=n of a minimum prime number of prime numbers in the input input one n (0<=n <= 10^6)
Prime number in the smallest prime number of the output >=n
Sample input
234
Sample output
335
Hint Source
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include < Cmath>using namespace Std;int b[1500001];int n;int vis[5000010];int a[1500001];int pan () //prime sieve { int m=sqrt ( 2000000+0.5); memset (vis,0,sizeof (Vis)); for (int i=2;i<=m;i++) if (!vis[i]) for (int j=i*i;j<=2000000;j+=i) vis[j]=1;} int P () { int num=85714;<span id= "Transmark" ></span> for (int i=1100003;i>=2;i--) { if (vis[i]==0) { b[num]=i; if (vis[num]==0) { a[i]=num; } else a[i]=a[i+1]; num--; } else {a[i]=a[i+1];}}} int main () { pan (); P (); while (~SCANF ("%d", &n)) { if (n==0| | n==1) printf ("2\n"); cout<<a[n]; else printf ("%d\n", B[a[n]]); }
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Sdut 3305 Prime number in prime (prime sieve)