Cod sursa(job #1773671)

Utilizator shantih1Alex S Hill shantih1 Data 8 octombrie 2016 09:00:38
Problema Ciurul lui Eratosthenes Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.56 kb
#include <fstream>
#include <iostream>
using namespace std;

ifstream fin("ciur.in");
ofstream fout("ciur.out");

int n , i , j , s, nr;

int main() {

    fin >> n ;
    
    j = 1 ;
    
    for ( i = 2 ; i <= n ; i ++ ){
        
        while ( j <= i ){
            
            if ( i % j == 0 ){
                
                s = s + 1 ;
            }
            
            j = j + 1 ;
        }
        
        if ( s == 2 ){
            
            nr = nr + 1 ;
        }
        
        j = 1 ;
        s = 0 ;
    }
    
    fout << nr << endl ;
}