Cod sursa(job #1500725)

Utilizator dazxAndrei dazx Data 12 octombrie 2015 16:56:13
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.04 kb
            /*
             *   _ _ _ _ _ _ _
             *  |             |
             *  |             |   __
             *  |         _ _ |  / _|
             *  |        |    |  | |
             *  |_ _ _ _ |    |_ | | _ _ _ _ _ _
             *  |        |    |                 |
             *  |        |_ _ |                 |
             *  |       /     \      _ _        |_
             *  |_ _ _ /       \_ _ /   \_ _ _ _ _|
             *         |       |   |     |
             *          \ _ _ /     \ _ /
             */

#include <bits/stdc++.h>

using namespace std;

ifstream f("ciur.in");
ofstream g("ciur.out");

const int NMax =  2e6 + 5;

int k;
int Prime[NMax];
bool viz[NMax];

void ciur(int n){

    k = 1;
    for(int i = 3; i <= n; i = i + 2){
    if(viz[i] == 0){
        k++;
        Prime[k] = i;
        for(int j = 3 * i; j <= n; j = j + (2*i)){
            viz[j]=1;

            }
        }

    }
}

int main()
{
    int n;
    f>>n;
    ciur(n);
    g<<k;
    return 0;
}