結果

問題 No.2111 Sum of Diff
ユーザー tamato
提出日時 2022-10-28 21:30:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 366 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 105,472 KB
最終ジャッジ日時 2024-07-06 00:31:15
合計ジャッジ時間 4,386 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    for i, a in enumerate(A):
        ans = (ans + (a * (pow(2, N - i - 1, mod) - 1)) % mod) % mod
        ans = (ans - (a * (pow(2, i, mod) - 1)) % mod) % mod
    print(ans)


if __name__ == '__main__':
    main()
0