結果
問題 |
No.1237 EXP Multiple!
|
ユーザー |
|
提出日時 | 2020-09-25 23:46:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 22 ms / 2,000 ms |
コード長 | 674 bytes |
コンパイル時間 | 1,739 ms |
コンパイル使用メモリ | 195,380 KB |
最終ジャッジ日時 | 2025-01-14 21:44:51 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> #define rep(i, ss, ee) for (int i = ss; i < ee; ++i) using namespace std; using ll = long long; const ll MOD = 1e9 + 7; inline ll f(ll k) { ll sum = 1; for (ll ii = 1; ii <= k; ++ii) { sum *= ii; } return sum; } void solve() { int N; cin >> N; vector<ll> a(N); ll mx = 0; rep(i, 0, N) { cin >> a[i]; if (a[i] == 0) { cout << -1 << endl; return; } mx = max(mx, a[i]); } if (mx >= 4) { cout << MOD << endl; return; } ll ans = 1; for (ll x : a) { ans *= pow(x, f(x)); } ans = MOD % ans; cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); solve(); }