Cod sursa(job #3284566)
| Utilizator | Data | 11 martie 2025 21:37:59 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
#define int long long
const int NMAX = 1e6 + 5;
int a[NMAX];
void ciur(int n)
{
a[0] = a[1] = 1;
for(int i = 2; i <= n; i++)
a[i] = i - 1;
for(int i = 2; i <= n; i++)
for(int j = 2 * i; j <= n; j += i)
a[j] -= a[i];
}
signed main()
{
int n, ans = 0;
fin >> n;
ciur(n);
for(int i = 1; i <= n; i++)
ans += 2 * a[i];
fout << ans - 1;
return 0;
}
