Cod sursa(job #2428246)

Utilizator AlexNeaguAlexandru AlexNeagu Data 4 iunie 2019 13:22:36
Problema Fractii Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.5 kb
#include<bits/stdc++.h>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int n, x;
const int xmax = 100005;
int phi[xmax];
void indicatorul_euler()
{
  for (int i = 1; i <= xmax - 5; i++) phi[i] = i - 1;
  for (int i = 1; i <= xmax; i++)
  for (int j = i + i; j <= xmax; j += i)
  phi[j] -= phi[i];
}
int main()
{
  indicatorul_euler();
  long long s = 0;
  fin >> n;
  for (int i = 1; i <= n; i++)
  s += phi[i];
  fout << 1ll * s * 2 + 1 << "\n";
  return 0;
}