Cod sursa(job #1662573)
| Utilizator | Data | 24 martie 2016 21:25:51 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <fstream>
using namespace std;
ifstream cin("fractii.in");
ofstream cout("fractii.out");
int erath[1000005];
long long n, ans;
int main() {
cin >> n;
for(int i = 1; i <= n; ++i) {
erath[i] = i - 1;
}
for(int i = 2; i <= n / 2 + 1; ++i) {
for(int j = 2 * i; j <= n; j += i) {
erath[j] -= erath[i];
}
}
for(int i = 1; i <= n; ++i) {
ans += erath[i];
}
ans *= 2;
++ans;
cout << ans << '\n';
return 0;
}
