結果

問題 No.2111 Sum of Diff
ユーザー tktk_snsntktk_snsn
提出日時 2022-10-28 21:36:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 313 ms / 2,000 ms
コード長 288 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 10,520 KB
実行使用メモリ 29,924 KB
最終ジャッジ日時 2023-09-20 04:25:38
合計ジャッジ時間 5,082 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,768 KB
testcase_01 AC 16 ms
7,808 KB
testcase_02 AC 307 ms
29,876 KB
testcase_03 AC 215 ms
23,084 KB
testcase_04 AC 56 ms
11,372 KB
testcase_05 AC 309 ms
29,836 KB
testcase_06 AC 306 ms
29,924 KB
testcase_07 AC 86 ms
13,392 KB
testcase_08 AC 112 ms
15,120 KB
testcase_09 AC 35 ms
9,720 KB
testcase_10 AC 41 ms
10,212 KB
testcase_11 AC 158 ms
18,564 KB
testcase_12 AC 150 ms
17,956 KB
testcase_13 AC 103 ms
14,508 KB
testcase_14 AC 258 ms
25,948 KB
testcase_15 AC 293 ms
29,484 KB
testcase_16 AC 135 ms
16,996 KB
testcase_17 AC 313 ms
29,912 KB
testcase_18 AC 106 ms
14,728 KB
testcase_19 AC 236 ms
24,964 KB
testcase_20 AC 311 ms
29,908 KB
testcase_21 AC 20 ms
8,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
N = int(input())
A = list(map(int, input().split()))


two = [1] * (N + 10)
for i in range(1, N + 10):
    two[i] = two[i-1] * 2 % mod

ans = 0
for i, a in enumerate(A):
    ans += a * (two[N - i - 1] - 1) % mod
    ans -= a * (two[i] - 1) % mod
    ans %= mod
print(ans)
0