Cod sursa(job #3189378)

Utilizator ezluciPirtac Eduard ezluci Data 4 ianuarie 2024 23:40:38
Problema Fractii Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.73 kb
using namespace std;
#ifdef EZ
   #include "./ez/ez.h"
   const string FILE_NAME = "test";
#else
   #include <bits/stdc++.h>
   const string FILE_NAME = "fractii";
#endif
#define mp make_pair
#define ll long long
#define pb push_back
#define fi first
#define se second
#define cin fin
#define cout fout
ifstream fin (FILE_NAME + ".in");
ofstream fout (FILE_NAME + ".out");


const int nMAX = 1e6;
const int M = 1e9 + 7;

int phi[nMAX + 1];


void genPhi()
{
   iota(phi, phi + nMAX+1, 0);

   for (int i = 2; i <= nMAX; ++i)
      if (phi[i] == i)
         for (int j = i; j <= nMAX; j += i)
            phi[j] = phi[j] / i * (i-1);
}


int main()
{
   genPhi();

   int n;   cin >> n;
   cout << accumulate(phi + 1, phi + n+1, 0LL) * 2 - 1;
}