View Code of Problem 102

#include<iostream>
using namespace std; 
int gcd(int x,int y)
{
    return(x%y==0?y:gcd(y,x%y));
}
int main()
{
    int x,y;
	while(cin>>x>>y) {
	    int ans=0;
		if(y%x){
	        cout<<0<<endl;
	        continue;
	    }
	    else if(x==y){
	    	cout<<1<<endl;
	    	continue;
		}
	    y=y/x; 
	    for(int i=1; i*i<=y; i++)
	    {
	        if(y%i==0&&gcd(i,y/i)==1)
				ans+=2;
	    }
	    cout<<ans<<endl;
    } 
}

Double click to view unformatted code.


Back to problem 102