#include<iostream> using namespace std; #include<cmath> long long getnum(long long a,long long b) //求最大公约数 { if(b==0) { return a; } return getnum(b,a%b); } int main() { long long x,y; while(cin>>x>>y) { int sum=0; if(y%x!=0) { cout<<0<<endl; } else if(y==x) { cout<<1<<endl; } else { for(long long i=1;i<=sqrt(x*y);i++) //p*q=x*y { if(x*y%i==0&&getnum(i,x*y/i)==x) { sum+=2; } } cout<<sum<<endl; } } return 0; } |
Double click to view unformatted code.