Cod sursa(job #1509369)
| Utilizator | Data | 23 octombrie 2015 19:36:21 | |
|---|---|---|---|
| Problema | Fractii | Scor | 100 |
| Compilator | cpp | 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 NMax = 1e6 + 5;
long long int v[NMax];
int main(){
int n;
fin >> n;
for(int i = 1; i <= n; i++){
v[i] = i;
}
for(int i = 2; i <= n; i++){
if(v[i] == i){
for(int j = i; j <= n; j += i){
v[j] = (v[j] / i) * (i - 1);
}
}
}
long long int ans = 0;
for(int i = 2; i <= n; i++){
ans += v[i];
}
fout << 2 * ans + 1;
return 0;
}
