結果
問題 | No.2717 Sum of Subarray of Subsequence |
ユーザー |
|
提出日時 | 2024-01-26 17:56:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 96 ms / 2,000 ms |
コード長 | 651 bytes |
コンパイル時間 | 4,183 ms |
コンパイル使用メモリ | 252,584 KB |
最終ジャッジ日時 | 2025-02-18 22:47:55 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;vector<int> a(n);for (int i = 0; i < n; i++) cin >> a[i];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;}