View Code of Problem 102

#include<stdio.h>
#include<math.h>
#include<string.h>

int main()
{
    long a,b,i;
    while(scanf("%ld %ld",&a,&b) != EOF)
    {
        int sum = 0;
        if(a == b)
            sum = 1;
        else
        {
            for(i = a;i <= sqrt(a*b);i++)
            {
                if(a*b%i == 0)
                {
                    long int m = i,n = a*b/i;
                    while(m)
                    {
                        int t = n%m;
                        n = m;
                        m = t;
                    }
                    if(n == a)
                        sum+=2;
                }
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 102