結果

問題 No.1237 EXP Multiple!
ユーザー hgotohgoto
提出日時 2020-10-27 23:05:15
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 756 bytes
コンパイル時間 1,964 ms
コンパイル使用メモリ 198,644 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 03:29:45
合計ジャッジ時間 3,233 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 13 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 12 ms
4,376 KB
testcase_13 AC 13 ms
4,376 KB
testcase_14 AC 13 ms
4,380 KB
testcase_15 AC 13 ms
4,376 KB
testcase_16 AC 13 ms
4,376 KB
testcase_17 AC 13 ms
4,376 KB
testcase_18 AC 13 ms
4,376 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long ans = 1;
  const int md = (int)1e9 + 7;
  auto fact = [](int n) {
    int ret = n;
    while (--n) ret *= n;
    return ret;
  };
  auto pow = [](int n, int p) {
    int ret = 1;
    while (p--) ret *= n;
    return ret;
  };
  while (n--) {
    int a;
    cin >> a;
    if (a >= 4) {
      cout << md << '\n';
      return 0;
    }
    ans *= pow(a, fact(a));
    if (ans == 0) {
      cout << -1 << '\n';
      return 0;
    }
    if (ans >= md) {
      cout << md << '\n';
      return 0;
    }
  }
  cout << md % ans << '\n';
  return 0;
}
0