結果

問題 No.2111 Sum of Diff
ユーザー first_vilfirst_vil
提出日時 2022-08-23 23:04:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 280 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 385 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 107,284 KB
最終ジャッジ日時 2024-04-19 13:15:54
合計ジャッジ時間 4,929 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
51,840 KB
testcase_01 AC 49 ms
51,584 KB
testcase_02 AC 270 ms
102,016 KB
testcase_03 AC 189 ms
93,724 KB
testcase_04 AC 77 ms
66,688 KB
testcase_05 AC 274 ms
102,016 KB
testcase_06 AC 278 ms
102,204 KB
testcase_07 AC 99 ms
71,648 KB
testcase_08 AC 124 ms
76,544 KB
testcase_09 AC 65 ms
62,848 KB
testcase_10 AC 70 ms
64,128 KB
testcase_11 AC 154 ms
83,840 KB
testcase_12 AC 145 ms
83,584 KB
testcase_13 AC 114 ms
74,624 KB
testcase_14 AC 219 ms
99,072 KB
testcase_15 AC 259 ms
107,284 KB
testcase_16 AC 129 ms
80,640 KB
testcase_17 AC 280 ms
101,888 KB
testcase_18 AC 103 ms
74,880 KB
testcase_19 AC 213 ms
97,920 KB
testcase_20 AC 259 ms
101,800 KB
testcase_21 AC 54 ms
60,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

int1 = lambda x: int(x) - 1

# input = lambda: sys.stdin.buffer.readline()
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
i1 = lambda: int1(input())
mi = lambda: map(int, input().split())
mi1 = lambda: map(int1, input().split())
li = lambda: list(mi())
li1 = lambda: list(mi1())
lli = lambda n: [li() for _ in range(n)]

INF = float("inf")
# mod = int(1e9 + 7)
mod = 998244353

n = ii()
a = li()

p = 0
m = 0
for i in range(n):
    if 0 < i:
        m += a[i] * (pow(2, i, mod) - 1)
        m %= mod
    if i + 1 < n:
        p += a[i] * (pow(2, n - 1 - i, mod) - 1)
        p %= mod

print((p - m + mod) % mod)
0