View Code of Problem 102

#include <stdio.h>
#include <math.h> 
using namespace std;
int main(){
    long int a,b;
	while( ~scanf("%ld %ld", &a, &b )){
		int sum = 0;
		if( a == b ){
			sum =1;
		}else{
			for(long int i=a; i<=sqrt(a*b); i++ ){
				if( a*b%i == 0 ){
			        long int t = a*b/i;
			        long int a1 = i;
					while( a1 ){
						long int d = t%a1;
						t = a1;
						a1 = d;
					}
					if( t == a ){
						sum += 2;
					}
				}
			}
		}
		
		printf("%d\n", sum );
	}

	return 0;
	
}

Double click to view unformatted code.


Back to problem 102