View Code of Problem 102

#include<iostream>
#include<string.h>
#include <math.h>
using namespace std;
int gcd(int x,int y)
{
    return(x%y==0?y:gcd(y,x%y));
}
int main(){
	int x,y;
	while(scanf("%d %d",&x,&y)!=EOF)
	{
		if(y%x!=0)
			printf("0\n");
		else if(x==y)
			printf("1\n");
		else{
			int a=y/x;
			int count=2;
			for(int i=2;i<sqrt(a);i++)
				if(a%i==0&&gcd(a/i,i)==1)
					count+=2;
			printf("%d\n",count);
		}	
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 102