結果
問題 | No.2717 Sum of Subarray of Subsequence |
ユーザー |
|
提出日時 | 2024-01-26 18:04:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 96 ms / 2,000 ms |
コード長 | 733 bytes |
コンパイル時間 | 4,096 ms |
コンパイル使用メモリ | 251,616 KB |
最終ジャッジ日時 | 2025-02-18 22:48:22 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS#include <bits/stdc++.h>using namespace std;#include <atcoder/all>using namespace atcoder;using mint = modint998244353;int main() {// input_from_file("input.txt");// output_to_file("output.txt");int n;cin >> n;assert(1 <= n && n <= (int)2e5);vector<int> a(n);for (int i = 0; i < n; i++) {cin >> a[i];assert(0 <= a[i] && a[i] < 998244353);}vector<mint> pow2(n);pow2[0] = 1;for (int i = 1; i < n; i++) pow2[i] = pow2[i - 1] * 2;mint res;for (int i = 0; i < n; i++) {int l = i;int r = n - 1 - i;mint lc = (l == 0 ? 1 : (l + 2) * pow2[l - 1]);mint rc = (r == 0 ? 1 : (r + 2) * pow2[r - 1]);res += a[i] * lc * rc;}cout << res.val() << endl;}