結果

問題 No.1237 EXP Multiple!
ユーザー MisterMister
提出日時 2020-09-25 21:35:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 737 bytes
コンパイル時間 749 ms
コンパイル使用メモリ 69,028 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 15:00:13
合計ジャッジ時間 1,835 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>

using lint = long long;
constexpr lint MOD = 1000000007;

void solve() {
    int n;
    std::cin >> n;

    lint prod = 1;
    while (n--) {
        lint x;
        std::cin >> x;
        if (x == 0) {
            prod = 0;
            break;
        } else if (prod < MOD && x <= 3) {
            switch (x) {
                case 2:
                    prod *= 4;
                    break;
                case 3:
                    prod *= 729;
                    break;
            }
        }
        prod = std::min(prod, MOD + 1);
    }

    std::cout << (prod == 0 ? -1 : MOD % prod) << "\n";
}

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

    solve();

    return 0;
}
0