結果

問題 No.1237 EXP Multiple!
ユーザー bonKotsubonKotsu
提出日時 2020-12-16 18:23:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 1,479 ms
コンパイル使用メモリ 166,592 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 09:44:04
合計ジャッジ時間 2,843 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;


#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>

ll memo[4] = {0, 1, 4, 729};

const ll MOD = 10e8 + 7;
int main() {
  ll n;
  cin >> n;

  ll ans = 1;

  bool flag = true;

  rep(i, n) {
    int a;
    cin >> a;

    if (a >= 4) {
      cout << MOD << endl;
      return 0;
    } 

    if (a == 0) {
      cout << -1 << endl;
      return 0;
    }

    if (flag) {
      ans *= memo[a];
    }

    if (ans > MOD) {
      flag = false;
    }
  }

  cout << MOD % ans << endl;

}
0