I have written a similar one before. This should be more difficult than that.
(X/gcd (x, y, z) * (y/gcd (x, y, z) * (z * gcd (x, y, z) = lcm (x, y, z)/gcd (x, y, z );
Unique decomposition of LCM (x, y, z)/gcd (x, y, z;
For each PI ^ AI, X/gcd (x, y, z), y/gcd (x, y, z), Z/gcd (x, y, z) there must be one to take 0, one to take AI, and the other to any;
The repeat principle is removed;
(AI + 1) * (AI + 1) * (AI + 1)-2 * ai * Ai + (ai-1) * (ai-1) * (ai-1 );
PS: When AI is set to 1, it is 6;
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 using namespace std; 5 6 int sign[100000]; 7 int pri[100000]; 8 int tot; 9 10 void getpri (){11 memset (sign,0,sizeof sign);12 for (int i=2;i<100000;i++)13 if (!sign[i])14 for (int j=i*2;j<100000;j+=i)15 sign[j]=1;16 tot=0;//cout<<"error";17 for (int i=2;i<100000;i++)18 if (!sign[i])19 pri[tot++]=i;20 }21 22 int mm[100000];23 24 int getpow (int n){25 return n*n*n;26 }27 28 void solved (int s){29 int num=0;30 int ans=1;31 int x=s;32 memset (mm,0,sizeof mm);33 for (int i=0;i<tot;i++){//cout<<x<<endl;34 if (x%pri[i]==0){35 while (x%pri[i]==0){36 mm[i]++;37 x/=pri[i];38 }39 ans*=getpow(mm[i]+1)-2*getpow(mm[i])+getpow(mm[i]-1);//cout<<mm[i]<<" "<<pri[i]<<endl;40 num++;41 }42 }43 if (x!=1)44 ans*=6;45 cout<<ans<<endl;46 47 }48 49 int main (){50 getpri();51 int t;52 int g,l;53 cin>>t;54 while (t--){55 cin>>g>>l;56 if (l%g!=0){57 cout<<"0"<<endl;58 continue ;59 }60 solved (l/g);61 62 }63 return 0;64 }
HDU 4497 GCD and LCM