Cod sursa(job #823185)

Utilizator crst_svCraciunescu Cristian crst_sv Data 24 noiembrie 2012 18:36:13
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include<iostream>
#include<fstream>
using namespace std;

int cmmdc(int x,int y)
{
	if(x>1&&y>1)
		for(int i=x;i>=2;i=i-1)
			if((x%i==0)&&(y%i==0))
				return 0;
		return 1;
}

int main()
{
	int N,nr=0;
	ifstream f_in;
	fstream f_out;
	f_in.open("fractii.in");
	f_out.open("fractii.out");
	f_in>>N;
	for(int i=1;i<=N;i=i+1)
		for(int j=1;j<=N;j=j+1)
		{
			/*if(cmmdc(i,j))
			{
				//f_out<<i<<"/"<<j<<"  ";
				nr++;
			}*/
			int gasit=0;
			if(i>1&&j>1)
				for(int k=i;k>=2&&gasit==0;k=k-1)
					if((i%k==0)&&(j%k==0))
						gasit=1;
			if(gasit==0)
				nr++;
		}
		f_out<<nr<<endl;
	return 0;
}