Cod sursa(job #1727663)
Utilizator | Data | 11 iulie 2016 14:14:12 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.36 kb |
#include<fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int nr,i,j,x[1000000],h;
int main()
{
long n;
fin>>n;nr=n;
for(i=2;i<=n;i++){
for(h=1;h<=n;h++)
x[h]=0;
for(j=2;j<=i;j++)
if(i%j==0)
{
for(h=1;h<=n/j;h++)
x[j*h]=1;
}for(h=1;h<=n;h++)
if(!x[h])
nr++;}
fout<<nr;
}