gcd,lcm HDU4497
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 6 int arr[100000]; 7 8 using namespace std; 9 10 int main() 11 { 12 int n; 13 cin>>n; 14 while(n--) 15 { 16 long long a,b; 17 long long ans=0; 18 int num=0; 19 memset(arr,0,sizeof(arr)); 20 scanf("%I64d%I64d",&a,&b); 21 if(b%a==0) 22 { 23 ans=1; 24 int c=b/a; 25 double s=sqrt((double)c); 26 for(int i=2;i<=s;i++) 27 { 28 if(c%i==0) 29 num++; 30 while(c%i==0) 31 { 32 arr[num]++; 33 c=c/i; 34 } 35 } 36 if(c!=1) 37 { 38 num++; 39 arr[num]++; 40 } 41 for(int i=1;i<=num;i++) 42 { 43 ans=ans*(3*2+6*(arr[i]-1)); 44 } 45 } 46 cout<<ans<<endl; 47 } 48 return 0; 49 }