結果

問題 No.2717 Sum of Subarray of Subsequence
ユーザー kusaf_
提出日時 2024-04-16 00:55:30
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 496 bytes
コンパイル時間 2,562 ms
コンパイル使用メモリ 250,452 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-06 09:18:26
合計ジャッジ時間 4,486 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll N;
  cin >> N;

  vector<ll> A(N);
  for(auto &i : A) { cin >> i; }

  vector<mint> v(N, 1);
  mint p = 1;
  for(ll i = 1; i < N; i++, p *= 2) { v[i] = p * (i + 2); }

  mint ans = 0;
  for(ll i = 0; i < N; i++) { ans += v[i] * v[N - i - 1] * A[i]; }

  cout << ans.val() << "\n";
}
0