Cod sursa(job #1460481)

Utilizator bublesbubles tiganu bubles Data 12 iulie 2015 19:23:30
Problema Ciurul lui Eratosthenes Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.77 kb
#include <fstream>
#include <iostream>

using namespace std;
int ciur(unsigned int len){
    bool v[2000000];
    int x = 0;
   for(unsigned int i = 2; i <= len; i++){
    v[i] = 0;
   }
   for(unsigned int i = 2; i <= len; i++){
        if(i*2 <= len){
            v[i * 2] = 1;
            if(i*3 <= len){
                v[i * 3] = 1;
                if(i*5 <= len){
                    v[i * 5] = 1;
                    if(i*7 <= len)
                        v[i * 7] = 1;
                }
            }
        }
       if(v[i] != 1){
            x++;
       }
   }
   return x;
}
int main(){
    unsigned int x;
    ifstream fin("ciur.in");
    ofstream fout("ciur.out");
    fin >> x;
    cout << "asdfasdf";
    fout << ciur(x);
    return 0;
}