Cod sursa(job #3346469)
| Utilizator | Data | 13 martie 2026 19:26:08 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
int ph[1000005];
void phi()
{
for(int i=1;i<=1000000;i++)
ph[i]=i;
for(int i=2;i<=1000000;i++)
{
if(ph[i]==i)
{
for(int j=i;j<=1000000;j+=i)
ph[j]-=ph[j]/i;
}
}
}
int main()
{
long long n,s=0;
in>>n;
phi();
for(int i=2;i<=n;i++)
s+=ph[i];
out<<s*2+1;
return 0;
}
