結果
問題 | No.2550 MORE! JUMP! MORE! |
ユーザー |
![]() |
提出日時 | 2023-11-25 14:15:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 681 bytes |
コンパイル時間 | 952 ms |
コンパイル使用メモリ | 64,896 KB |
実行使用メモリ | 6,656 KB |
最終ジャッジ日時 | 2024-09-26 10:41:31 |
合計ジャッジ時間 | 3,746 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 40 |
ソースコード
#include<iostream>using namespace std;typedef long long ll;const ll MOD=998244353;ll power(ll x,ll n);int main(){ll n;ll array[200005];cin>>n;for(int i=1;i<=n;i++){cin>>array[i];}if(n==1){cout<<array[1]<<endl;return(0);}ll add=power(2,n-3);ll cnt[200005];cnt[1]=power(2,n-2);for(int i=2;i<n;i++){cnt[i]=(cnt[i-1]+add)%MOD;}cnt[n]=((cnt[n-1]+add)*2)%MOD;ll ans=0;for(int i=1;i<=n;i++){ans=(ans+array[i]*cnt[i])%MOD;}cout<<ans<<endl;}ll power(ll x,ll n){if(n<=0){return(1);}ll root=power(x,n/2);root=(root*root)%MOD;if(n&1){root=(root*x)%MOD;}return(root);}