結果

問題 No.2111 Sum of Diff
ユーザー nephrologistnephrologist
提出日時 2022-10-28 22:23:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 488 bytes
コンパイル時間 1,518 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 107,800 KB
最終ジャッジ日時 2023-09-20 05:25:58
合計ジャッジ時間 4,106 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,092 KB
testcase_01 AC 72 ms
71,364 KB
testcase_02 AC 130 ms
107,656 KB
testcase_03 AC 111 ms
97,332 KB
testcase_04 AC 88 ms
78,628 KB
testcase_05 AC 129 ms
107,712 KB
testcase_06 AC 127 ms
107,684 KB
testcase_07 AC 90 ms
82,100 KB
testcase_08 AC 96 ms
85,700 KB
testcase_09 AC 86 ms
76,724 KB
testcase_10 AC 86 ms
77,276 KB
testcase_11 AC 102 ms
90,612 KB
testcase_12 AC 101 ms
90,296 KB
testcase_13 AC 96 ms
84,364 KB
testcase_14 AC 118 ms
100,448 KB
testcase_15 AC 125 ms
107,020 KB
testcase_16 AC 103 ms
88,528 KB
testcase_17 AC 126 ms
107,800 KB
testcase_18 AC 94 ms
84,428 KB
testcase_19 AC 114 ms
100,372 KB
testcase_20 AC 127 ms
107,700 KB
testcase_21 AC 83 ms
76,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline
mod = 998244353
n = int(input())
A = list(map(int, input().split()))

pow2 = [1] * (n + 1)
for i in range(n):
    pow2[i + 1] = 2 * pow2[i] % mod

ans = 0
for i in range(n):
    left = i
    right = n - i - 1
    ans += pow2[left] * A[i] % mod
    ans %= mod
    ans += (pow2[right + 1] - 1) * A[i] % mod
    ans %= mod
    ans -= pow2[right] * A[i] % mod
    ans %= mod
    ans -= (pow2[left + 1] - 1) * A[i] % mod
    ans %= mod
print(ans)
0