Cod sursa(job #2405198)

Utilizator gabi08Dron Ionut-Gabriel gabi08 Data 14 aprilie 2019 09:20:31
Problema Fractii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <iostream>
#include <fstream>
#define nmax 1000005
using namespace std;

ifstream in("fractii.in");
ofstream out("fractii.out");

int n, sol;
int v[nmax] = {1};

int main() 
{
	in >> n;
	for (int i = 2; i <= n; ++i)
	{
		if (i == 1)
			v[1] = 0;
		else
		{
			for (int j = i; j <= n; j += i)
			{
				v[i]++;
				if (i < j)
					v[j]++;
			}
		}
	}
	for (int i = 1; i <= n; ++i)
		sol += n - v[i];
	out << sol;
	system("pause");
}