結果

問題 No.1237 EXP Multiple!
ユーザー umezoumezo
提出日時 2020-09-25 23:00:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 628 bytes
コンパイル時間 2,840 ms
コンパイル使用メモリ 197,780 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2023-09-10 16:07:25
合計ジャッジ時間 4,732 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 33 ms
6,472 KB
testcase_06 WA -
testcase_07 AC 34 ms
6,468 KB
testcase_08 WA -
testcase_09 AC 33 ms
6,548 KB
testcase_10 AC 35 ms
6,476 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 35 ms
6,580 KB
権限があれば一括ダウンロードができます

ソースコード

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