結果

問題 No.2111 Sum of Diff
ユーザー kokatsukokatsu
提出日時 2022-11-13 16:35:45
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 419 bytes
コンパイル時間 4,886 ms
コンパイル使用メモリ 203,996 KB
実行使用メモリ 12,640 KB
最終ジャッジ日時 2023-09-04 18:56:44
合計ジャッジ時間 6,288 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 45 ms
12,512 KB
testcase_03 AC 30 ms
9,572 KB
testcase_04 AC 8 ms
4,460 KB
testcase_05 AC 46 ms
12,564 KB
testcase_06 AC 44 ms
12,640 KB
testcase_07 AC 12 ms
6,128 KB
testcase_08 AC 16 ms
6,500 KB
testcase_09 AC 5 ms
4,384 KB
testcase_10 AC 5 ms
4,384 KB
testcase_11 AC 21 ms
7,324 KB
testcase_12 AC 21 ms
7,344 KB
testcase_13 AC 14 ms
6,184 KB
testcase_14 AC 35 ms
10,932 KB
testcase_15 AC 43 ms
12,344 KB
testcase_16 AC 19 ms
6,992 KB
testcase_17 AC 44 ms
12,576 KB
testcase_18 AC 15 ms
6,528 KB
testcase_19 AC 33 ms
10,244 KB
testcase_20 AC 45 ms
12,584 KB
testcase_21 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

enum long MOD = 998244353;

void addMod(ref long x, long y) {
    x = (x + y) % MOD;
}

void main() {
    long N;
    readf("%d\n", N);

    auto a = readln.chomp.split.to!(long[]);

    auto pow2 = new long[](N+1);
    pow2[0] = 1;
    foreach (i; 1 .. N+1) pow2[i] = (pow2[i-1] * 2) % MOD;

    long res;
    foreach (i, x; a) {
        addMod(res, x*(pow2[N-i-1]-pow2[i]+MOD));
    }

    res.writeln;
}
0