Cod sursa(job #1662069)
| Utilizator | Data | 24 martie 2016 14:23:16 | |
|---|---|---|---|
| Problema | Fractii | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <fstream>
using namespace std;
ifstream cin("fractii.in");
ofstream cout("fractii.out");
int erath[1000005];
int n, ans;
int main() {
cin >> n;
for(int i = 1; i <= n; ++i) {
erath[i] = i - 1;
}
for(int i = 2; i <= n; ++i) {
/*if(erath[i] < i - 1) {
continue;
}*/
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;
}
