Cod sursa(job #381408)

Utilizator thebest001Neagu Rares Florian thebest001 Data 10 ianuarie 2010 15:29:27
Problema Mins Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <stdio.h>
long cmmdc(long a,long b)
{
   long r;
   while (b)
   {
      r=a%b;
      a=b;
      b=r;
   }
   return a;
}
int main()
{
   freopen("mins.in","r",stdin);
   freopen("mins.out","w",stdout);
   int n,m,i,j;
   long cate=0;
   scanf("%d %d",&m,&n);
   for (i=1;i<n;i++)
       for (j=1;j<m;j++)
       {
         if (cmmdc((long)i,(long)j)==1)
            cate++;
       }
   printf("%ld",cate);
   return 0;
}