結果
問題 | No.1325 Subsequence Score |
ユーザー |
![]() |
提出日時 | 2020-12-22 00:34:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 239 ms / 2,000 ms |
コード長 | 577 bytes |
コンパイル時間 | 3,071 ms |
コンパイル使用メモリ | 193,980 KB |
最終ジャッジ日時 | 2025-01-17 05:58:45 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#define rep(i,n) for (int i=0;i < (int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; const int MOD=998244353; ll modpow(ll x,ll n){ ll ans=1; while(n){ if(n&1) ans=ans*x%MOD; x=x*x%MOD; n/=2; } return ans; } int main(){ int n; cin>>n; vector<ll> A(n+1); rep(i,n) cin>>A[i+1]; if(n==1){ cout<<A[1]%MOD<<endl; return 0; } ll ans=0; for(ll i=1;i<=n;i++){ ans=(ans+A[i]*(i+1)%MOD)%MOD; } ans=ans*modpow(2LL,n-2)%MOD; cout<<ans<<endl; return 0; }