Cod sursa(job #2513290)

Utilizator kokitchyAlastor kokitchy Data 22 decembrie 2019 20:05:01
Problema Fractii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

int main()
{
	ifstream fin("fractii.in");
	ofstream fout("fractii.out");

	int n;
	fin >> n;

	int nr = 0;
	int a[100];
	for (int i = 1; i <= n; i++)
		a[i] = i - 1;

	for (int i = 2; i <= n; i++) {
		nr += a[i];
		for (int j = 2 * i; j <= n; j += i)
			a[j] -= a[i];
	}

	fout << 2 * nr + 1;

	fin.close(), fout.close();
}