Cod sursa(job #2588764)

Utilizator aser.cobaschiCobaschi Aser aser.cobaschi Data 25 martie 2020 13:49:39
Problema Fractii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
const int N=1000001;
int theta[N];
long long sol;
int main()
{
  f>>n;
  for(int i=1;i<=n;i++)
    theta[i]=i;
  theta[1]=0;
  for(int i=2;i<=n;i++)
    if(theta[i]==i)
  {
      for(int j=i;j<=n;j+=i)

        {
            theta[j]/=i;
            theta[j]*=i-1;
        }
  }
   for(int i=2;i<=n;i++)
        sol+=2*theta[i];
   g<<1+sol;
    return 0;
}