Cod sursa(job #1700469)
| Utilizator | Data | 10 mai 2016 16:42:24 | |
|---|---|---|---|
| Problema | Fractii | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
/********************
Created by Sburly
********************/
#include <fstream>
using namespace std;
int main()
{
ifstream f("fractii.in");
ofstream g("fractii.out");
long int n;
f >> n;
long int totient[n+1];
long int sol = 0;
for (long int i = 1; i <= n; ++i)
totient[i] = i-1;
for (long int i = 2; i <= n; ++i)
{
sol+=totient[i];
for (long int j = 2*i; j <= n; j += i)
totient[j] -= totient[i];
}
g << sol*2+1;
return 0;
}
