結果

問題 No.2111 Sum of Diff
ユーザー Carpenters-Cat
提出日時 2022-10-28 21:59:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 1,762 ms
コンパイル使用メモリ 192,252 KB
最終ジャッジ日時 2025-02-08 14:28:42
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll const m = 998244353;
int main () {
    int N;
    ll A[200020];
    cin >> N;
    for (int i = 0; i < N; i ++) {
        cin >> A[i];
    }
    ll bi = 1;
    ll ans = 0;
    for (int i = 0; i < N; i ++) {
        ans -= (A[i] * (bi - 1)) % m;
        if (ans < 0) {
            ans += m;
        }
        ans += (A[N - i - 1] * (bi - 1)) % m;
        if (ans >= m) {
            ans -= m;
        }
        bi *= 2;
        bi %= m;
    }
    cout << ans << endl;
}
0