全WA求调
查看原帖
全WA求调
1271969
Nahida_Buer楼主2024/12/1 11:03

样例是全过的。但是一提交就全WA 用的是递推求阶乘,费马小定理求逆元 求大佬调

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll x=0;char ch=getchar();
	while(ch>'9'||ch<'0')ch=getchar();
	while (ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-48;ch=getchar();}
	return x;
}
ll n,m;
int c[10005],tot;
const ll mod=1e9+7;
ll jc[120005];
ll ans=1;
ll qpow(ll a,int b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod,b>>=1;
	} 
	return res;
}
void pw(int a){
	jc[0]=jc[1]=1;
	for(int i=2;i<=a;i++)jc[i]=(jc[i-1]*i)%mod;
} 
ll C(int n,int m){
	return (jc[n]*qpow(jc[m]*jc[n-m],mod-2))%mod;
}
int main(){
	n=read();m=read();
	pw(120000);
	for(ll i=2;i*i<=n;i++)
		if(n%i==0){
			tot++;
			while(n%i==0)n/=i,c[tot]++;
		}
	if(n>1)c[++tot]=1;
	for(ll i=1;i<=tot;i++)ans=ans*C(c[i]+m-1,m-1)%mod;
	ans=ans*qpow(2,m-1)%mod;
	printf("%lld\n",ans);
	return 0;
}
2024/12/1 11:03
加载中...