結果
問題 | No.1237 EXP Multiple! |
ユーザー |
|
提出日時 | 2020-09-25 22:18:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 900 bytes |
コンパイル時間 | 1,493 ms |
コンパイル使用メモリ | 165,844 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 08:35:05 |
合計ジャッジ時間 | 2,584 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr char newl = '\n'; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; ll ans = 1; for (int i = 0; i < n; i++) { int a; cin >> a; if (a == 0) { ans = -1; break; } else if (a == 1) { continue; } else if (a >= 5) { ans = 1000000008; continue; } int hoge = 1; for (int i = 1; i < a + 1; i++) { hoge *= i; } for (int i = 0; i < hoge; i++) { if (a * ans > 1000000007) { ans = 1000000008; break; } else { ans *= a; } } } if (ans <= 0) cout << -1 << newl; else cout << 1000000007 % ans << newl; return 0; }