mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
file rename to standards
This commit is contained in:
parent
0e3a57ab3f
commit
412d3ff1a2
@ -1,12 +1,12 @@
|
|||||||
#include<iostream>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
char prime[100000000];
|
char prime[100000000];
|
||||||
|
|
||||||
void Sieve(int64_t n) {
|
void Sieve(int64_t n) {
|
||||||
memset(prime, '1', sizeof(prime)); // intitize '1' to every index
|
memset(prime, '1', sizeof(prime)); // intitize '1' to every index
|
||||||
prime[0] = '0'; // 0 is not prime
|
prime[0] = '0'; // 0 is not prime
|
||||||
prime[1] = '0'; // 1 is not prime
|
prime[1] = '0'; // 1 is not prime
|
||||||
for (int p = 2; p * p <= n; p++) {
|
for (int p = 2; p * p <= n; p++) {
|
||||||
if (prime[p] == '1') {
|
if (prime[p] == '1') {
|
||||||
for (int i = p * p; i <= n; i += p)
|
for (int i = p * p; i <= n; i += p)
|
||||||
@ -15,7 +15,6 @@ void Sieve(int64_t n) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
Sieve(100000000);
|
Sieve(100000000);
|
||||||
int64_t n;
|
int64_t n;
|
Loading…
Reference in New Issue
Block a user