結果

問題 No.2111 Sum of Diff
ユーザー 7iz6
提出日時 2022-11-02 16:42:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 672 bytes
コンパイル時間 1,536 ms
コンパイル使用メモリ 166,868 KB
実行使用メモリ 8,264 KB
最終ジャッジ日時 2024-07-17 05:56:52
合計ジャッジ時間 4,090 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL<<60;
const int MOD = 998244353;

long long pow2[200006];
long long cum[200006] = {};

int main() {
    int n; cin >> n;
    pow2[0] = 1;
    long long ans = 0;
    long long a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++) {
        pow2[i] = pow2[i-1] * 2 % MOD;
        cum[i] = cum[i-1] + pow2[i-1];
    }
    for(int i = 0; i < n; i++) {
        ans += cum[abs(n-1-i)] * a[i];
        ans %= MOD;
        ans -= cum[abs(i-0)] * a[i];
        ans %= MOD;
        ans += MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}
0