Cod sursa(job #1510908)

Utilizator NineshadowCarapcea Antonio Nineshadow Data 25 octombrie 2015 19:17:10
Problema Fractii Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <fstream>
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
int main()
{
    int n;
    in >> n;
    int *v = new int[++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);
    int r = 0;
    for(int i = 2; i < n; i++){
        r += v[i];
    }
    out << (r<<1) + 1;
    return 0;
}