Cod sursa(job #3349557)
| Utilizator | Data | 31 martie 2026 17:09:06 | |
|---|---|---|---|
| Problema | Fractii | Scor | 80 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
const int N = 1e6+5;
int n;
int euler(int x){
int ans = x;
for(int p = 2; p*p <=x; p++){
if(x % p == 0){
while(x % p == 0) x/=p;
ans -= ans / p;
}
}
if(x > 1) ans -= ans/x;
return ans;
}
int main(){
fin >> n;
ll sol = 1;
for(int i = 2; i<=n; i++){
sol += 2*euler(i);
}
fout << sol;
return 0;
}