Cod sursa(job #2644507)
| Utilizator | Data | 24 august 2020 20:04:28 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 20 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
// test.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include<fstream>
using namespace std;
int v[201];
int main()
{
int n, i, j;
int nr = 0;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
fin >> n;
v[0] = 1;
v[1] = 1;
for (i = 2; i <= n; i++)
{
if (v[i] == 0)
for (j = 2; j <= n / i; j++)
v[i * j] = 1;
if (v[i - 1] == 0)
nr++;
}
if (v[n] == 0)
nr++;
fout << nr;
}
