結果

問題 No.1239 Multiplication -2
ユーザー りあんりあん
提出日時 2020-09-05 10:17:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 727 bytes
コンパイル時間 2,538 ms
コンパイル使用メモリ 201,572 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-08-18 15:06:25
合計ジャッジ時間 7,830 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 11 ms
4,380 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int M = 998244353;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<long long> pw(n);
    pw[0] = 1;
    int inv = (M + 1) / 2;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        pw[i + 1] = pw[i] * inv % M;
    }
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        int b = 1;
        for (int j = i; j < n; ++j) {
            b *= a[j];
            if (b == -2) {
                int c = j - i + 2 - (i == 0) - (j == n - 1);
                ans = (ans + pw[c]) % M;
            }
            if (b == 0 || abs(b) > 2) break;
        }
    }
    cout << ans << '\n';
    return 0;
}
0