結果
| 問題 | 
                            No.1237 EXP Multiple!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-10-27 23:05:15 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 756 bytes | 
| コンパイル時間 | 1,998 ms | 
| コンパイル使用メモリ | 192,052 KB | 
| 最終ジャッジ日時 | 2025-01-15 16:05:37 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 14 WA * 5 | 
ソースコード
#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;
}