結果
問題 | No.2717 Sum of Subarray of Subsequence |
ユーザー |
|
提出日時 | 2024-02-01 21:41:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 151 ms / 2,000 ms |
コード長 | 580 bytes |
コンパイル時間 | 4,081 ms |
コンパイル使用メモリ | 250,180 KB |
最終ジャッジ日時 | 2025-02-19 01:02:57 |
ジャッジサーバーID (参考情報) |
judge3 / 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;}