Cod sursa(job #2923693)
| Utilizator | Data | 17 septembrie 2022 21:30:39 | |
|---|---|---|---|
| Problema | Fractii | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("fractii.in");
ofstream fout ("fractii.out");
const int NM = 1e6 + 5;
long long f[NM];
void precalc(){
for (int i = 2; i <= NM; i++){
f[i] = i;
}
for (int i = 2; i * i <= NM; i++){
if (f[i] == i){
for (int j = 1; j * i <= NM; j++){
f[i * j] = f[i * j] / i * (i - 1);
}
}
}
for (int i = 2; i <= NM; i++){
f[i] += f[i - 1];
}
}
int main(){
ios_base::sync_with_stdio(false);
precalc();
int x; fin >> x;
fout << 2 * f[x] + 1;
}
