結果

問題 No.2111 Sum of Diff
ユーザー dachengzdachengz
提出日時 2022-11-16 10:33:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 285 bytes
コンパイル時間 418 ms
コンパイル使用メモリ 81,652 KB
実行使用メモリ 106,648 KB
最終ジャッジ日時 2023-10-17 09:12:08
合計ジャッジ時間 3,166 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,320 KB
testcase_01 AC 36 ms
53,320 KB
testcase_02 AC 97 ms
101,284 KB
testcase_03 AC 72 ms
94,056 KB
testcase_04 AC 46 ms
66,096 KB
testcase_05 AC 97 ms
101,284 KB
testcase_06 AC 100 ms
101,284 KB
testcase_07 AC 51 ms
71,912 KB
testcase_08 AC 55 ms
75,460 KB
testcase_09 AC 42 ms
61,748 KB
testcase_10 AC 45 ms
64,708 KB
testcase_11 AC 63 ms
82,664 KB
testcase_12 AC 62 ms
82,540 KB
testcase_13 AC 54 ms
74,144 KB
testcase_14 AC 79 ms
97,736 KB
testcase_15 AC 89 ms
106,648 KB
testcase_16 AC 61 ms
80,636 KB
testcase_17 AC 96 ms
101,284 KB
testcase_18 AC 54 ms
74,204 KB
testcase_19 AC 75 ms
97,040 KB
testcase_20 AC 97 ms
101,284 KB
testcase_21 AC 42 ms
59,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

A = list(A)
pow2_lo = 1
inv2 = (mod + 1) // 2
pow2_hi = pow(2, N - 1, mod)
ans = 0
for a in A:
    ans = (ans + a * (pow2_hi - pow2_lo)) % mod
    pow2_lo = pow2_lo * 2 % mod
    pow2_hi = pow2_hi * inv2 % mod
print(ans)
0