library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub kisepichu/library

:warning: Eratosthenes
(lib/util/eratosthenes.hpp)

Code

#pragma once
int cn[MAXN]; // prime:0
void erat(lint n){
	for(int i=2; i<=n ++i){
		if(!cn[i]){
			for(int j=2*i; j<=n; j+=i)cn[j]=1;
			//i is prime
		}
	}
}

/*
* @title eratosthenes
*/
#line 2 "lib/util/eratosthenes.hpp"
int cn[MAXN]; // prime:0
void erat(lint n){
	for(int i=2; i<=n ++i){
		if(!cn[i]){
			for(int j=2*i; j<=n; j+=i)cn[j]=1;
			//i is prime
		}
	}
}

/*
* @title eratosthenes
*/
Back to top page