#include<stdio.h> int gcd(long p,long q){ return (p%q==0)?q:gcd(q,p%q); } int main(){ long x,y; while(scanf("%ld %ld",&x,&y)!=EOF){ if(x>y){ int t=x; x=y; y=t; } if(y%x!=0){ printf("0\n"); }else if(y==x){ printf("1\n"); }else{ int sum=0; for(long p=1;p*p<=(x*y);p++){ long q; if((x*y)%p==0){ q=(x*y)/p; if(gcd(p,q)==x){ sum+=2; } } } printf("%d\n",sum); } } return 0; } |
Double click to view unformatted code.