Cod sursa(job #272788)

Utilizator chibicitiberiuChibici Tiberiu chibicitiberiu Data 7 martie 2009 19:55:52
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include<fstream.h>
int main()
{
	int n,test=0;
	int tj, ti;

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

	in>>n;

	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++) {
			if (i>1 && j>1 && i==j) continue;
			if (j==1) {test++; continue; }
			ti=i;tj=j;
			while(ti!=tj)
				if (ti>tj) ti=ti-tj;
				else tj=tj-ti;
			if (tj==1) test++;
			}

	out<<test;

                                      
	in.close();
	out.close();

	return 0;
}