求第n个素数是多少(0~3000000)
#include <iostream>
#include"cstdio"
#include"cstring"
using namespace std;
bool prime[50000050];
int rec[5000000], cnt;
void init_prime_table(int n)
{
cnt = 0;
memset(prime, true, sizeof(prime));
prime[0] = prime[1] = false;
for (int i = 2; i <= n; ++i)
{
if (prime[i])
rec[cnt++] = i;
for (int j = 0; j < cnt; ++j)
{
if(i * rec[j] > n) break;
prime[i * rec[j]] = false;
if (i % rec[j] == 0)
break;
}
}
}
int main()
{
int n,k,x=1;
init_prime_table(50000000);
while(scanf("%d",&k)&&k){
printf("Case %\d: %d\n",x++,rec[k-1]);
}
}