結果

問題 No.1237 EXP Multiple!
ユーザー sirosaisirosai
提出日時 2022-09-04 22:50:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 963 bytes
コンパイル時間 605 ms
コンパイル使用メモリ 63,880 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 21:56:36
合計ジャッジ時間 2,208 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//答え「で」10^9 + 7を割った余りなので、答え > 10^9 + 7 なら速攻で0を返してOK。
//注意点 A = [ ... 4 0 ... ] のケースでは、mod ではなくて -1 を返す必要がある。
#include <iostream>
#define int long long
using namespace std;

int mod = 1000000007;
int n;
int a[200000];

signed main() {
    int i;
    int ans = 1;
    cin >> n;

    for (i = 0; i < n; i++) {
        cin >> a[i];
        // 答えが0なら-1を返す(お約束)
        if (a[i] == 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    for (i = 0; i < n; i++) {
        if (a[i] >= 4) {
            cout << mod << endl;
            return 0;
        }
        if (a[i] == 2) {
            ans *= 4;
        }
        if (a[i] == 3) {
            ans *= 729;
        }
        if (ans > mod) {
            cout << mod << endl;
            return 0;
        }
    }

    cout << mod % ans << endl;
    return 0;
}
0