Cod sursa(job #3345469)
| Utilizator | Data | 9 martie 2026 19:04:28 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int n;
int a[1000005];
int main()
{
for(int i= 1; i <=1000000; ++i)a[i]=i;
for(int i = 2; i <= 1000000; ++i)
{
if(a[i]==i)
{
a[i]--;
for(int j = i *2; j <= 1000000; j += i)
{
a[j]-=a[j]/i;
}
}
}
fin>>n;
long long s=0;
for(int i = 2;i <= n; ++i)
{
s+=1LL*a[i];
}
fout<<s*2+1;
return 0;
}
