結果
| 問題 |
No.2111 Sum of Diff
|
| コンテスト | |
| ユーザー |
nephrologist
|
| 提出日時 | 2022-10-28 22:23:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 95 ms / 2,000 ms |
| コード長 | 488 bytes |
| コンパイル時間 | 145 ms |
| コンパイル使用メモリ | 82,476 KB |
| 実行使用メモリ | 103,808 KB |
| 最終ジャッジ日時 | 2024-07-06 01:33:50 |
| 合計ジャッジ時間 | 2,620 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
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)
nephrologist