結果

問題 No.1237 EXP Multiple!
ユーザー finefine
提出日時 2020-09-25 22:18:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 900 bytes
コンパイル時間 1,432 ms
コンパイル使用メモリ 163,952 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 17:26:21
合計ジャッジ時間 2,711 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
            continue;
        }

        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