#include <stdio.h> #include <math.h> int gcd(int a,int b){ while(b){ int t=b; b=a%b; a=t; } return a; } int main(){ int x,y; while(scanf("%d %d",&x,&y)!=EOF){ int max=x>=y?x:y; int min=x>=y?y:x; if(max%min!=0){ printf("%d\n",0); }else if(max==min){ printf("%d\n",1); }else{ int i=max/min; int count=2; for(int j=2;j<sqrt(i);j++){ if(i%j==0&&gcd(i/j,j)==1){ count+=2; } } printf("%d\n",count); } } } |
Double click to view unformatted code.