結果

問題 No.1237 EXP Multiple!
ユーザー SSRSSSRS
提出日時 2020-09-25 21:42:11
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 3,075 ms
コンパイル使用メモリ 200,712 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 17:22:39
合計ジャッジ時間 3,648 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  bool zero = false;
  for (int i = 0; i < N; i++){
    if (A[i] == 0){
      zero = true;
    }
  }
  if (zero){
    cout << -1 << endl;
  } else {
    bool big = false;
    long long ans = 1;
    for (int i = 0; i < N; i++){
      if (A[i] >= 4){
        big = true;
        break;
      } else {
        if (A[i] == 2){
          ans *= 4;
        }
        if (A[i] == 3){
          ans *= 729;
        }
        if (ans > MOD){
          big = true;
          break;
        }
      }
    }
    if (big){
      cout << MOD << endl;
    } else {
      cout << MOD % ans << endl;
    }
  }
}
0