結果
問題 | No.2717 Sum of Subarray of Subsequence |
ユーザー |
|
提出日時 | 2024-02-01 21:41:19 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 580 bytes |
コンパイル時間 | 3,888 ms |
コンパイル使用メモリ | 263,368 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-28 16:55:36 |
合計ジャッジ時間 | 5,801 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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() { 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); } mint pow2; if (n == 1) pow2 = mint(4).inv(); else if (n == 2) pow2 = mint(2).inv(); else pow2 = mint(2).pow(n - 3); mint res; for (int i = 0; i < n; i++) { res += pow2 * a[i] * (i + 2) * (n - i + 1); } cout << res.val() << endl; }