Cod sursa(job #3318767)
| Utilizator | Data | 28 octombrie 2025 18:56:17 | |
|---|---|---|---|
| Problema | Fractii | Scor | 80 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
long long euler(int n){
long long ans = n;
for(int i = 2; i*i <= n; i++){
if(n % i == 0){
while(n % i == 0) n /= i;
ans -= ans / i;
}
}
if(n > 1) ans -= ans / n;
return ans;
}
int main(){
int n;
fin >> n;
long long s = 1;
for(int i = 2; i <= n; i++){
s += 2LL * euler(i);
}
fout << s << "\n";
return 0;
}
