結果

問題 No.1237 EXP Multiple!
ユーザー umezo
提出日時 2020-09-25 23:00:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 628 bytes
コンパイル時間 1,681 ms
コンパイル使用メモリ 193,516 KB
最終ジャッジ日時 2025-01-14 21:26:08
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 5 WA * 10 RE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

const int MAX = 410000;
const int MOD = 1000000007;

ll fac[MAX];

void init(){
  fac[0]=fac[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
  }
}

ll modpow(ll x,ll n){
  ll ans=1;
  while(n){
    if(n&1) ans=ans*x %MOD;
    x=x*x %MOD;
    n/=2;
  }
  return ans;
}

int main() {
  init();

  int n;
  cin>>n;
  
  int ans=1;
  rep(i,n){
    int x;
    cin>>x;
    ans=(ans*modpow(x,fac[x]))%MOD;
  }
  if(ans==0) cout<<-1<<endl;
  else cout<<ans<<endl;
  
}
0