結果

問題 No.1237 EXP Multiple!
ユーザー umezoumezo
提出日時 2020-09-26 01:17:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 701 bytes
コンパイル時間 2,180 ms
コンパイル使用メモリ 200,228 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 18:09:17
合計ジャッジ時間 3,892 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

const int MOD=1e9+7;

int main(){
  int n;
  cin>>n;
  
  vector<int> A(5);
  rep(i,n){
    int x;
    cin>>x;
    if(x>3) A[4]++;
    else A[x]++;
  }
  
  ll ans=1;
  if(A[0]>0){
    cout<<-1<<endl;
    return 0;
  }
  else if(A[4]>0){
    cout<<MOD<<endl;
    return 0;
  }
  else{
    rep(i,A[3]){
      ans*=729;
      if(ans>MOD){
        cout<<MOD<<endl;
        return 0;
      }
    }
    rep(i,A[2]){
      ans*=4;
      if(ans>MOD){
        cout<<MOD<<endl;
        return 0;
      }
    }
  }
  cout<<MOD%ans<<endl;
  
  return 0;
}
0