Cod sursa(job #1628319)

Utilizator CiurezAndreiCiurez Marius-Andrei CiurezAndrei Data 3 martie 2016 22:53:23
Problema Fractii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("fractii.in");
ofstream fout("fractii.out");

unsigned long long F[1000010], N;
unsigned long long solution;

int main()
{
    fin >> N;

    for(int i = 1; i <= N; i ++)
    {
        F[i] = i;
    }

    for(int i = 2; i <= N; i ++)
    {
        if(F[i] == i)
            for(int j = i; j <= N; j += i)
            {
                F[j] *= (i - 1);
                F[j] /= i;
            }
            solution += F[i];
    }

    fout << solution * 2 + 1;


    return 0;
}