Atcoder_ABC230F
点击查看代码
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
const ll mod=998244353;
ll dp[maxn],pre[maxn];
map<ll,int>mp;
ll a[maxn];
int main(){
#ifdef lmj_debug
freopen("1.in","r",stdin);
#endif
int n;
cin>>n;
for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
for (int i=1;i<=n;i++) pre[i]=pre[i-1]+a[i];
dp[1]=1;
for (int i=1;i<n;i++){
dp[i+1]=dp[i]*2-dp[mp[pre[i]]];
dp[i+1]=(dp[i+1]+mod)%mod;
mp[pre[i]]=i;
}
cout<<dp[n]<<endl;
return 0;
}