Cod sursa(job #3309974)
| Utilizator | Data | 10 septembrie 2025 21:58:57 | |
|---|---|---|---|
| Problema | Fractii | Scor | 30 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include<bits/stdc++.h>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int n, sum, i, j;
vector<int> v(1000001);
void phi_1_to_n(int n)
{
for(int i = 0; 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] -= v[j] / i;
}
}
}
int main()
{
fin>> n;
phi_1_to_n(n);
sum = 0;
for(i = 1; i <= n; i++)
sum += v[i];
fout<< sum*2-1;
return 0;
}
