考虑对每个 做质因数分解,则对每个质数,我们可以独立地去考虑它的情况数(像枚举二进制位),最后相乘即可。
然后考虑每个质数,设 在 中出现了 次(如 在 中出现了 次),则有 种情况。
每个 的质因数数是 级的,所以每个测试点要考虑的质数数量不超过 。
#include <bits/stdc++.h>
// using pii=std::pair<int, int>;
const int mod(1000000007);
std::mt19937 mr(std::mt19937(time(0)));
struct Hash {
int operator() (const int & x) const {
static int xr(mr());
return x^xr;
}
};
std::bitset<500000+5> isp;
int minfact[500000+5];
int n, x;
int prime[500000+5];
std::unordered_set<int, Hash> st;
void solve() {
std::cin>>n>>x;
st.clear();
for(int i(1); i<=n; i++) {
std::cin>>x;
while(x!=1) {
int p(minfact[x]);
st.insert(p);
prime[p]++;
x/=p;
}
}
int ans(1);
for(auto i : st) {
ans=(long long)ans*(prime[i]+1)%mod;
}
std::cout<<ans<<"\n";
for(auto i : st) prime[i]=0;
}
int main() {
n=500000;
for(int i(2); i<=n; i++) if(!isp[i]) {
minfact[i]=i;
if((long long)i*i>n) continue;
for(int j(i*i); j<=n; j+=i) minfact[j]=i, isp[j]=1;
}
std::ios::sync_with_stdio(0);
std::cin.tie(0);
int _;
std::cin>>_;
while(_--) solve();
return 0;
}