結果

問題 No.1237 EXP Multiple!
ユーザー finefine
提出日時 2020-09-25 22:17:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 878 bytes
コンパイル時間 1,435 ms
コンパイル使用メモリ 163,376 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-10 15:32:32
合計ジャッジ時間 5,068 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr char newl = '\n';

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    ll ans = 1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        if (a == 0) {
            ans = -1;
            break;
        } else if (a == 1) {
            continue;
        } else if (a >= 5) {
            ans = 1000000008;
        }

        int hoge = 1;
        for (int i = 1; i < a + 1; i++) {
            hoge *= i;
        }

        for (int i = 0; i < hoge; i++) {
            if (a * ans > 1000000007) {
                ans = 1000000008;
                break;
            } else {
                ans *= a;
            }
        }
    }
    
    if (ans <= 0) cout << -1 << newl;
    else cout << 1000000007 % ans << newl;

    return 0;
}
0