Cod sursa(job #2577078)
Utilizator | Rusu Raluca rusu.raluca | Data | 8 martie 2020 13:14:44 |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
const int maxn = 1000005;
int n;
long long int rez = 1;
int a[maxn];
int main(){
in >> n;
for(int i = 2; 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 * (i - 1);
rez += a[i] * 2;
}
out << rez;
return 0;
}