Cod sursa(job #2498803)
Utilizator | Data | 24 noiembrie 2019 14:16:24 | |
---|---|---|---|
Problema | Fractii | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.42 kb |
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
unsigned v[1000001], n, s=0;
ifstream f("fractii.in");
ofstream g("fractii.out");
int main ()
{
f>>n;
for(int i=2;i<=n;i++)
{
v[i]=i-1;
}
for(int i=2;i<=n;i++)
{
s+=v[i];
for(int j=2*i;j<=n;j+=i)
{
v[j]-=v[i];
}
}
g<<2*s+1;
return 0;
}