Cod sursa(job #156305)
| Utilizator | Data | 12 martie 2008 14:30:55 | |
|---|---|---|---|
| Problema | Pairs | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.42 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++)
f>>a[i];
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;
}