Cod sursa(job #1905719)
| Utilizator | Data | 6 martie 2017 10:28:17 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <fstream>
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
const int nmax=1000000;
int v[nmax+1];
int main()
{
int n;
in>>n;
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] /= i;
v[j] *= (i - 1);
}
}
}
long long cnt=0;
for(int i=2; i<=n; i++)
{
cnt+=v[i];
}
out<<cnt*2+1;
return 0;
}
