Cod sursa(job #2855009)
| Utilizator | Data | 21 februarie 2022 22:43:37 | |
|---|---|---|---|
| Problema | Fractii | Scor | 30 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int n;
int ind[1000005];
bool ciur[1000005];
unsigned long long ans;
int main()
{
fin >> n;
for(int i = 2; i <= n; i++)
ind[i] = i;
for(int i = 2; i <= n; i++)
if(!ciur[i])
for(int j = i; j <= n; j += i)
ind[j] = ind[j] * (i - 1) / i, ciur[j] = 1;
for(int i = 2; i <= n; i++)
ans += ind[i] * 2;
fout << ans + 1;
return 0;
}
