Cod sursa(job #2231187)
Utilizator | Data | 13 august 2018 13:32:18 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <bits/stdc++.h>
#define lsb(x) x & -x
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
const int NMAX = 1000005;
long long a[NMAX];
int main() {
int n;
in >> n;
long long sol = 1;
for(int i = 1; i <= n; i ++)
a[i] = i;
for(int i = 2; i <= n; i ++) {
if(a[i] == i)
for(int j = i; j <= n; j += i)
a[j] = a[j] * (i - 1) / i;
sol += (2LL * a[i]);
}
out << sol;
return 0;
}