結果
問題 |
No.2717 Sum of Subarray of Subsequence
|
ユーザー |
|
提出日時 | 2024-04-05 22:34:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 478 bytes |
コンパイル時間 | 1,756 ms |
コンパイル使用メモリ | 196,708 KB |
最終ジャッジ日時 | 2025-02-20 21:47:43 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; constexpr int MOD=998244353; void ch(ll &a,ll b){ a=(a+b)%MOD; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin>>N; vector A(N,0ll); for(ll &i:A)cin>>i; vector pow2(N+3,499122177ll); for(int i=1;i<N+3;i++){ pow2[i]=pow2[i-1]*2%MOD; } ll ans=0; for(int i=0;i<N;i++){ ch(ans,((pow2[i]*(i+2))%MOD)*((pow2[N-1-i]*(N+1-i))%MOD)%MOD*A[i]); } cout<<ans<<'\n'; }