結果
| 問題 |
No.2717 Sum of Subarray of Subsequence
|
| コンテスト | |
| ユーザー |
hongrock
|
| 提出日時 | 2024-04-05 22:36:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 866 bytes |
| コンパイル時間 | 2,363 ms |
| コンパイル使用メモリ | 194,320 KB |
| 最終ジャッジ日時 | 2025-02-20 21:49:10 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define mp make_pair
using 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 - 1ll * 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;
}
hongrock