The meaning of problems
Xiaoqiu want to know how many arrays \ (a_1, a_2, ..., a_k \) satisfies \ (gcd (a_1, a_2, ..., a_k) = d \) and \ (lcm (a_1, a_2, a_k ...) = n-\) , two arrays as different, as long as the presence of a number of different positions of the two
Thinking
Although this question is not the original title
The \ (d, n \) prime factorisation, for each quality factor, a factor of at least a minimum number of, at least a factor of the maximum number, can be used repellent capacity, i.e. Collection - a + 2 does not satisfy Satisfy
Code
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int k,d,n;
ll quickpow(ll a,ll b)
{
ll ret=1;
while(b)
{
if(b&1) ret=ret*a%mod;
a=a*a%mod;
b>>=1;
}
return ret;
}
int main()
{
cin>>k>>d>>n;
ll ans=1;
for(int i=2;i*i<=n;++i)
{
if(n%i==0)
{
int cnt1=0,cnt2=0;
while(n%i==0) ++cnt1,n/=i;
while(d%i==0) ++cnt2,d/=i;
if(cnt1==cnt2) continue;//注意判相等
ans = ans * ((quickpow(cnt1-cnt2+1,k) - 2ll * quickpow(cnt1-cnt2,k) + quickpow(cnt1-cnt2-1,k))%mod) %mod;
}
}
if(d==1 && n>1) ans = ans * (quickpow(2,k)-2) %mod;
cout<<(ans%mod+mod)%mod<<endl;
return 0;
}