Cod sursa(job #2698261)

Utilizator alexisgaming1234Partac Alexis Matei alexisgaming1234 Data 21 ianuarie 2021 16:25:09
Problema Fractii Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.8 kb
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
ifstream fin ("fractii.in");
ofstream fout ("fractii.out");
const int MAX = 10000;
main ()
{
  int N, s = 0, vector[MAX], sol = 0;
  fin >> N;
  for (int c = 2; c <= N; c++)
    vector[c] = c - 1;
    for(int c = 2; c <= N; c++){
        sol = sol + vector[c];
        for (int j = 2 * c; j <= N; j += c)
            vector[j] -= vector[c];}
  fout<<2* sol +1;
   
  return 0;
}