移项后是个分数,分离常数项出来得到
容易知道x一定大于b,所以就是看ab有多少个因子个数
直接sqrt计算会TLE
所以预处理出来1e6以内的素数即可
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+50;
bool vis[N];
int pri[N],tot;
void init(){
for(ll i=2;i<N;i++){
if(!vis[i]){
pri[tot++]=i;
for(ll j=i*i;j<N;j+=i) vis[j]=1;
}
}
}
int main(){
init();
int T;cin>>T;
while(T--){
ll x,y;cin>>x>>y;
ll ans=1;
ll q=x*y;
for(int i=0;i<tot;i++){
if(q%pri[i]==0){
int cnt=0;
while(q%pri[i]==0) q/=pri[i],++cnt;
ans*=(cnt+1);
}
}
if(q!=1) ans*=2;
cout<<ans<<endl;
}
return 0;
} 
京公网安备 11010502036488号