zyz的题解:https://www.zhihu.com/question/61218881
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define N 1000003
#define p 1000000007
#define LL long long
using namespace std;
int mu[N],a[N],cnt[N],h[N],g[N],n,pd[N],pr[N],f[N];
LL ksm(LL num,int x)
{
LL ans=1,tmp=num%p;
x=(x%(p-1)+p-1)%(p-1);
while (x)
{
if (x&1) ans=ans*tmp%p;
x>>=1,tmp=tmp*tmp%p;
}
return ans;
}
int main()
{
scanf("%d",&n);
int mx=0;register int i,j;
for (i=1;i<=n;i++) scanf("%d",&a[i]),mx=max(a[i],mx);
for (i=1;i<=n;i++)
{
for (int x=1;x*x<=a[i];x++)
if (a[i]%x==0) h[x]=1,h[a[i]/x]=1;
}
mu[1]=1;
for (i=2;i<=mx;i++)
{
if (!pd[i])
{
pr[++pr[0]]=i;
mu[i]=-1;
}
for (j=1;j<=pr[0];j++)
{
if (pr[j]*i>mx) break;
pd[i*pr[j]]=1;
if (i%pr[j]==0) break;
mu[i*pr[j]]=-mu[i];
}
}
f[0]=0; f[1]=1;
for (i=2;i<=mx;i++) f[i]=(f[i-1]+f[i-2])%p;
for (i=1;i<=mx;i++)
{
if (!h[i]) continue;
for (j=i;j<=mx;j+=i) g[i]+=h[j]*mu[j/i];
}
LL ans=1;
for (i=1;i<=mx;i++) ans=ans*ksm(f[i],g[i])%p;
printf("%lld\n",ans);
}