Cod sursa(job #2782049)
Utilizator | Data | 11 octombrie 2021 14:59:28 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <bits/stdc++.h>
#define LL long long
using namespace std;
ifstream fin ("fractii.in");
ofstream fout ("fractii.out");
LL phi[1000005];
LL n, sol;
int main (){
fin>>n;
for(LL i=1; i<=n; i++)
phi[i]=i;
sol=1;
for(LL i=2; i<=n; i++){
if(phi[i] == i)
for(LL j=i; j<=n; j+=i)
phi[j] = phi[j] / i * (i-1);
sol += 2*phi[i];
}
fout<<sol;
return 0;
}