結果

問題 No.1237 EXP Multiple!
ユーザー iqueue02
提出日時 2020-09-25 23:35:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 1,687 ms
コンパイル使用メモリ 199,744 KB
最終ジャッジ日時 2025-01-14 21:42:02
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr ll mod = 1e9+7;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  if (a.front() == 0LL) {
    cout << -1 << endl;
    return 0;
  }
  if (a.back() >= 4LL) {
    cout << mod << endl;
    return 0;
  }
  ll res = 1;
  for (int i = 0; i < n; i++) {
    int fact = 1;
    for (int j = 0; j < a[i]; j++) fact *= (j + 1);
    for (int j = 0; j < fact; j++) res *= a[i]; 
    if (res > mod) {
      cout << mod << endl;
      return 0;
    }
  }
  cout << mod % res << endl;
  return 0; 
}
0