結果

問題 No.2111 Sum of Diff
ユーザー flygonflygon
提出日時 2022-10-28 21:52:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 429 ms / 2,000 ms
コード長 344 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 103,944 KB
最終ジャッジ日時 2023-09-20 04:46:48
合計ジャッジ時間 7,069 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
71,280 KB
testcase_01 AC 72 ms
71,256 KB
testcase_02 AC 429 ms
103,212 KB
testcase_03 AC 308 ms
101,124 KB
testcase_04 AC 125 ms
79,472 KB
testcase_05 AC 407 ms
103,388 KB
testcase_06 AC 408 ms
103,544 KB
testcase_07 AC 157 ms
83,552 KB
testcase_08 AC 185 ms
87,412 KB
testcase_09 AC 101 ms
76,444 KB
testcase_10 AC 107 ms
77,516 KB
testcase_11 AC 226 ms
92,916 KB
testcase_12 AC 232 ms
92,488 KB
testcase_13 AC 173 ms
85,732 KB
testcase_14 AC 338 ms
103,084 KB
testcase_15 AC 393 ms
102,732 KB
testcase_16 AC 209 ms
90,888 KB
testcase_17 AC 405 ms
103,220 KB
testcase_18 AC 175 ms
86,164 KB
testcase_19 AC 325 ms
103,944 KB
testcase_20 AC 404 ms
103,480 KB
testcase_21 AC 87 ms
76,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
aa = a[::1]
mod = 998244353
for i in range(n):
  aa[i] *= pow(2, n-i-1, mod)
  aa[i] %= mod
cml = aa[::1]
for i in range(n-1)[::-1]:
  cml[i] += cml[i+1]

ans = 0
for i in range(n-1):
  tmp =pow(2, n-i-1,mod)-1
  tmp %= mod
  ans += pow(2,i,mod)*(a[i]*tmp - cml[i+1])
  ans %= mod

print(ans)
0