传送门
文章目录
- 题意:
- 思路:
题意:
给三个数的lcmlcmlcm和gcdgcdgcd,求满足条件的三元组组合个数。
思路:
首先lcmmodgcd==0lcm\bmod gcd==0lcmmodgcd==0是有组合的条件,否则输出0。
现在可知lcm(x′,y′,z′)=lcm(x,y,z)gcd(x,y,z),gcd(x′,y′,z′)=1lcm(x^{'},y^{'},z^{'})=\frac{lcm(x,y,z)}{gcd(x,y,z)},gcd(x^{'},y^{'},z^{'})=1lcm(x′,y′,z′)=gcd(x,y,z)lcm(x,y,z),gcd(x′,y′,z′)=1,对aaa分解质因子得到p1u1p2u2...pnunp_1^{u_1}p_2^{u_2}...p_n^{u_n}p1u1p2u2...pnun,假设x′=p1i1p2i2...pnjn,y′=p1j1p2j2...pnjn,z′=p1k1p2k2...pnknx^{'}=p_1^{i_1}p_2^{i_2}...p_n^{j_n},y^{'}=p_1^{j_1}p_2^{j_2}...p_n^{j_n},z^{'}=p_1^{k_1}p_2^{k_2}...p_n^{k_n}x′=p1i1p2i2...pnjn,y′=p1j1p2j2...pnjn,z′=p1k1p2k2...pnkn。那么由于gcd(x′,y′,z′)=1gcd(x^{'},y^{'},z^{'})=1gcd(x′,y′,z′)=1,可知min(i1,j1,k1)=0min(i_1,j_1,k_1)=0min(i1,j1,k1)=0,max(i1,j1,k1)=u1max(i_1,j_1,k_1)=u_1max(i1,j1,k1)=u1,所以我们需要找出来一个位置取000,一个位置取u1u_1u1,其他的位置随意就好了。当前位置的答案即为A32∗u1=6∗u1A_3^2*u_1=6*u_1A32∗u1=6∗u1,那么ans=∑6∗uians=\sum6*u_ians=∑6∗ui。
//#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
#include<cctype>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<ctime>
#include<cstdlib>
#define X first
#define Y second
#define L (u<<1)
#define R (u<<1|1)
#define pb push_back
#define mk make_pair
#define Mid (tr[u].l+tr[u].r>>1)
#define Len(u) (tr[u].r-tr[u].l+1)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define db puts("---")
using namespace std;//void rd_cre() { freopen("d://dp//data.txt","w",stdout); srand(time(NULL)); }
//void rd_ac() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//AC.txt","w",stdout); }
//void rd_wa() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//WA.txt","w",stdout); }typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;const int N=1000010,mod=1e9+7,INF=0x3f3f3f3f;
const double eps=1e-6;LL g,l;int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);int _; scanf("%d",&_);while(_--){scanf("%lld%lld",&g,&l);if(l%g!=0) { puts("0"); continue; }LL x=l/g;map<int,int>mp;for(int i=2;i<=x/i;i++)if(x%i==0)while(x%i==0) x/=i,mp[i]++;if(x>1) mp[x]++;LL ans=1;for(auto x:mp) ans*=6*x.Y;printf("%lld\n",ans);}return 0;
}
/**/