Cod sursa(job #156301)

Utilizator ionel71089lescai ionel ionel71089 Data 12 martie 2008 14:28:25
Problema Pairs Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include<fstream.h>
#include<string.h>
main ()
{int a[100]={0},n=0,k=0,i=0,j=0,x=0,y=0;
ifstream f("pairs.in");
ofstream g("pairs.out");
f>>n;
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
{x=a[i];y=a[j];
/* rest=x%y;
while (rest>0)
x=y;y=rest;rest=x%y;
if (y==1 && a[i]!=a[j]) */
	 while (x!=y)
		{
		if (x>y)
		x=x-y;
		y=y-x;
		}
		if (x==1 && a[i]!=a[j])
	k=k+1;
}
g<<k;
return 0;
}