#include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #include<iostream> #include<algorithm> //#include <bits/stdc++.h> using namespace std; int gcd(int a,int b) { if(a<b) { int temp=a; a=b; b=temp; } while(b!=0) { int temp=a%b; a=b; b=temp; } return a; } int main() { long long int x,y; while(scanf("%lld %lld",&x,&y)!=EOF) { long long int sum=0; int j; if(x==y) { printf("1\n"); } else { for(int i=x; i<sqrt(y*x); i++) { if((x*y)%i==0) { j=x*y/i; if(gcd(i,j)==x) { sum++; } } } printf("%lld\n",sum*2); } } } |
Double click to view unformatted code.