Cod sursa(job #2849009)

Utilizator qMihaiMihai Blidaru qMihai Data 14 februarie 2022 12:54:13
Problema Fructe Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <fstream>
using namespace std;
int main()
{
    unsigned i, n, phi[999999];
    unsigned long long x = 0;
    ifstream fin("fractii.in");
    ofstream fout("fractii.out");
    fin>> n;
    for (i = 2; i <= n;phi[i]=i, ++i);
       for (i = 2; i <= n; ++i)
        if (phi[i] == i)
           for (unsigned j = i; j <= n; phi[j] /= i,phi[j]*=i - 1,j+=i);
    for (i = 2; i <= n; x+=phi[i++]*2);
    fout << x + 1;
}