Cod sursa(job #377423)
| Utilizator | Data | 24 decembrie 2009 14:37:45 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.38 kb |
#include<iostream>
#include<fstream>
using namespace std;
int phi[2000000];
int main()
{
fstream f("fractii.in",ios::in);
fstream x("fractii.out",ios::out);
long long n,g=0;
f>>n;
for (int i = 1; i <= n; ++i)
phi[i] = i-1;
for (int i = 2; i <= n; ++i)
for (int j = 2*i; j <= n; j += i)
phi[j] -= phi[i];
for(int i=2;i<=n;i++)
g=g+phi[i]*2;
x<<1+g;
}