Cod sursa(job #882755)

Utilizator lostsoulMunteanu Florin lostsoul Data 19 februarie 2013 14:22:04
Problema Pairs Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream f("pairs.in");
ofstream g("pairs.out");

int cmmdc(int a,int b)
{
if(a==b) return a;
else
if (a>b) return cmmdc(a-b,b);
else return cmmdc(a,b-a);
}

int main()

{int v[100];
int r=1,i,j,nr=0;
while(f>>v[r])
	r++;
  for(i=1;i<=r-1;i++)
	  for(j=i+1;j<=r-1;j++)
		  if(v[i]!=v[j] && cmmdc(v[i],v[j])==1)
			  nr++;
g<<nr;
return 0;
}