Cod sursa(job #2387014)

Utilizator oogaboogauvuvwevwevwe onyetenyevwe ugwemubwem ossas oogabooga Data 24 martie 2019 10:02:29
Problema Fractii Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <bits/stdc++.h>

using namespace std;

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

const int64_t MX = 1000005;

int64_t N, Ph[MX], F;

int main()
{
    in>>N;

    for(int i = 1; i <= N; ++i) Ph[i] = i - 1;

    for(int i = 2; i <= N; ++i)
        for(int j = 2 * i; j <= N; j += i)
            Ph[j] -= Ph[i];

    for(int i = 2; i <= N; ++i)
        F += Ph[i];

    F = 2 * F + 1;

    out << F;

    return 0;
}