很奇怪啊,莫名其妙就 T 了
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define MOD 1000000007
#define N 10000005
#define LL long long
using namespace std;
LL n,d[N],ans[N];
int pcnt,p[N],vis[N];
void euler() {
for (int i=2;i<N;i++) {
if (!vis[i]) p[++pcnt]=i;
for (int j=1;j<=pcnt and i*p[j]<N;j++) {
vis[i*p[j]]=1;
if (i%p[j]==0) break;
}
}
}
LL quickpow(LL a,LL k) {
LL res=1;
while (k) {
if (k&1) res=res*a%MOD;
a=a*a%MOD,k>>=1;
}
return res;
}
int main() {
// freopen("math.in","r",stdin);
// freopen("math.out","w",stdout);
ios::sync_with_stdio(0);
euler();
while (cin>>n) {
int cnt=0;
for (int i=1;p[i]<=n and i<=pcnt;i++)
while (n%p[i]==0) n/=p[i],d[++cnt]=p[i];
if (n>1) d[++cnt]=n;
sort(d+1,d+cnt+1); int tot=2;
LL res=1;
for (int i=1;i<=cnt;i++) {
int id=0; LL mul=0;
for (int j=2;j<=tot;j++)
if (!id or 1.0*mul*log10(p[id]*1.0)>1.0*(ans[j]+1)*(d[i]-1)*log10(p[j]*1.0))
id=j,mul=(ans[j]+1)*(d[i]-1);
++tot;
ans[id]+=mul;
}
for (int i=2;i<=tot;i++)
if (ans[i]) res=res*quickpow(p[i],ans[i])%MOD;
cout<<res<<endl;
}
return 0;
}