結果
問題 | No.1237 EXP Multiple! |
ユーザー |
|
提出日時 | 2020-09-25 23:13:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 141 ms / 2,000 ms |
コード長 | 811 bytes |
コンパイル時間 | 3,501 ms |
コンパイル使用メモリ | 197,768 KB |
最終ジャッジ日時 | 2025-01-14 21:32:17 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; const ll mod = int(1e9) + 7; int main() { ll N; cin >> N; vector<ll> a(N); rep(i, N) { cin >> a[i]; } sort(a.begin(), a.end()); if (a[0] == 0) { cout << -1 << endl; return 0; } ll ans = 1; rep(i, N) { if (a[i] >= 4) { cout << mod << endl; return 0; } ll div = 1; rep(j, a[i]) { div *= (j + 1); } // cerr << "div" << div << endl; rep(j, div) { ans *= a[i]; if (ans > (mod)) { cout << mod << endl; return 0; } } } cout << mod % ans << endl; return 0; }