結果

問題 No.1237 EXP Multiple!
コンテスト
ユーザー polyester
提出日時 2020-09-26 00:16:43
言語 C++17(clang)
(clang++ 22.1.2 + boost 1.90.0)
コンパイル:
clang++ -O2 -lm -std=c++1z -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 921 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 742 ms
コンパイル使用メモリ 151,092 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-31 19:11:22
合計ジャッジ時間 4,651 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other TLE * 1 -- * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  ll limit = 1000000007;
  int n;
  cin >> n;
  ll num = 1;
  for(int i = 0; i < n; i++) {
    ll tmp, a, cnt = 1;
    cin >> a;
    if(a < 2) {
      continue;
    }
    tmp = a;
    while(tmp--) {
      cnt *= (tmp + 1);
    }
    for(int j = 0; j < cnt; j++) {
      if(num > limit / a) {
        cout << limit << '\n';
        return 0;
      }
      num *= a;
      if(limit % num == 0) {
        cout << -1 << '\n';
        return 0;
      } else if(num > limit) {
        cout << limit << '\n';
        return 0;
      }
    }
  }
  if(limit % num == 0) {
    cout << -1 << '\n';
  } else {
    cout << limit % num << '\n';
  }
  return 0;
}
0