結果
問題 | No.2717 Sum of Subarray of Subsequence |
ユーザー |
![]() |
提出日時 | 2024-04-05 22:30:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 860 bytes |
コンパイル時間 | 1,768 ms |
コンパイル使用メモリ | 194,308 KB |
最終ジャッジ日時 | 2025-02-20 21:44:00 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 12 |
ソースコード
#include<bits/stdc++.h>using namespace std;#define pb emplace_back#define mp make_pairusing ll = long long;using pii = pair<int,int>;constexpr int mod = 998244353;constexpr int inf = 0x3f3f3f3f;constexpr int N = 2e5 + 10;int n, a[N];ll b[N];void _main(){cin >> n;for(int i=1; i<=n; ++i) cin >> a[i];if(n == 1){b[1] = 1;} else if(n == 2){b[1] = b[2] = 3;} else {ll x = 1, y = 4, z = 5;for(int i=4; i<=n; ++i){x = x * 2 % mod;y = (y * 2 + x) % mod;z = (z * 2 + x) % mod;}for(int i=1; i<=n; ++i){b[i] = (y * i + z - i * i % mod * x) % mod;if(b[i] < 0) b[i] += mod;}}ll ans = 0;for(int i=1; i<=n; ++i) ans += a[i] * b[i] % mod;cout << ans % mod << '\n';}int main(){ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);_main();return 0;}