Cod sursa(job #934490)

Utilizator PsychoRoAlex Buicescu PsychoRo Data 30 martie 2013 18:55:06
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <iostream>
#include <fstream>

std::ifstream fin("fractii.in");
std::ofstream fout("fractii.out");
//std::ifstream fin("date.in");
//std::ofstream fout("date.out");

long cmmdc(long a, long b)
{
	if(!b)
	{
		return a;
	}
	else
	{
		return cmmdc(b, a%b);
	}
}

void citeste()
{
	long n = 0;
	fin>>n;
	long nr = n;

	for(long i = 2 ; i <= n ; i++)
	{
		for(long j = i; j <= n ; j++)
		{
//			if(cmmdc(i, j) == 1)
			{
//				std::cout<<i<<" "<<j<<'\n';
				nr++;
			}
		}
	}
	nr = nr * 2 - 1;
//	std::cout<<'\n';
//	std::cout<<nr<<'\n';
	fout<<nr;
}

int main()
{
	citeste();
	return 0;
}