Demo entry 6760313

a

   

Submitted by Wky on Sep 12, 2018 at 14:05
Language: C++. Code size: 362 Bytes.

const int MAX_N (int)1e5+10
bool Is_Prime[MAX_N];
int Prime[MAX_N];
int cnt;
void getPrime(){
	memset(Is_Prime,true,sizeof(Is_Prime));
	Is_Prime[1]=false;
	cnt=0;
	for(int i=2;i<=N;i++){
		if(Is_Prime[i])
			Prime[++cnt]=i;
		for(int j=1;j<=cnt && i*Prime[j]<=cnt;j++){
			Is_Prime[ i*Prime[j] ]=false;
			if(i%Prime[j]==0)
				break;
		}
	}
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).