G: 又见模法师

G: 又见模法师

Time Limit: 1 s      Memory Limit: 128 MB     
 
#include <stdio.h>
const int MOD=1e9+7;
typedef long long LL;
LL pow_mod(LL a,LL k,int MOD)
{
  LL s=1;
  while(k)
  {
    if(k&1)
      s=s*a%MOD;
    a=a*a%MOD;
    k>>=1;
  }
  return s;
}

int p[200001];

int main()
{
  int m;
  scanf("%d",&m);
  for(int i=0;i<m;i++)
  {
    int t=0;
    scanf("%d",&t);
    p[t]++;
  }
  LL prod=1;
  for(int i=0;i<=200000;i++)
    prod=prod*(1+p[i])%((MOD-1)*2);
  LL ans=1;
  for(int i=0;i<=200000;i++)
  {
    if(p[i])
    {
      LL cnt=prod*p[i]/2%(MOD-1);
      ans=ans*pow_mod(i,cnt,MOD)%MOD;
    }
  }
  printf("%lld\n",ans);
  return 0;
}

 

posted @ 2018-12-04 20:09  知道了呀~  阅读(226)  评论(0编辑  收藏  举报