View Code of Problem 102

#include<iostream>  
#include<cmath>
using namespace std; 

inline long gcd(long a,long b){     
    if(b==0)return a;  
    return gcd(b,a%b);  
}  
int main(){  
    long n,m;  
    while(cin>>n>>m) {
    	long tot=0;
    	if(n==m){
    		cout <<1<<endl;
    		continue;
		}
    	for(long i=n;i<=sqrt(n*m);i+=n){    
        if(m%i==0){            
            	long j=(n*m)/i;      
            	if(gcd(i,j)==n)tot++;  
        	}  
    	}  
    	cout<<tot*2<<endl;  
    	
	}                
    
}  

Double click to view unformatted code.


Back to problem 102