cf 1009E
如何看待某cf2000分选手不会一道tag1900的题?
难。
考虑每段距离的贡献,
a[i]出现在位置j上,当且仅当j-i休息,并且中间的都不是休息的。
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 998244353; int n;ll a[1000005],bas[1000005],dp[1000005]; ll ans; int main(){ ios::sync_with_stdio(false); cin>>n;bas[0]=1; for(int i=1;i<=n;i++)cin>>a[i],bas[i]=bas[i-1]*2%mod; for(int i=1;i<=n;i++){ (ans+=a[i]*(bas[n-i]+bas[n-i-1]*(n-i)%mod)%mod)%=mod; } cout<<ans<<endl; }
转载于//www.cnblogs.com/MXang/p/11355587.html
还没有评论,来说两句吧...