Cod sursa(job #2195020)
| Utilizator | Data | 14 aprilie 2018 22:20:41 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int N;
int V[1000006];
int main()
{
fin>>N;
long long s=-1;
for(int i=1;i<=N;i++)
{
V[i] = i;
}
for(int i=2;i<=N;i++)
{
if (V[i] == i)
{
for(int j=i;j<=N;j+=i)
V[j] = V[j] - V[j]/i;
}
}
for(int i=1;i<=N;i++)
s = s + 2*V[i];
fout<<s;
return 0;
}
