Cod sursa(job #2628537)

Utilizator abcabc123abc abc abcabc123 Data 16 iunie 2020 11:43:35
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.33 kb
#include <fstream>

using namespace std;

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

int n, pr;
char v[2000001];

int main()
{
  fin >> n;
  for (int i = 2; i <= n; i++)
    if (v[i] != 'k') {
      pr++;
      for (int j = i + i; j <= n; j += i)
        v[j] = 'k';
    }
  fout << pr;
  return 0;
}