Cod sursa(job #3343454)
| Utilizator | Data | 27 februarie 2026 14:44:54 | |
|---|---|---|---|
| Problema | Fractii | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
const int DIM = 1e6 + 5;
int n;
long long ans;
int phi[DIM];
void Compute(int n);
int main()
{
fin >> n;
Compute(n);
for (int i = 2; i <= n; ++i)
ans += phi[i];
fout << (1LL * ans * 2 + 1);
return 0;
}
void Compute(int n)
{
for (int i = 2; i <= n; ++i)
phi[i] = i - 1;
phi[1] = 1;
for (int i = 2; i <= n; ++i)
for (int j = 2 * i; j <= n; j += i)
phi[j]--;
}
