提交时间:2022-10-04 11:28:34

运行 ID: 57483

#include<bits/stdc++.h> using namespace std; #define int long long const int mod=998244353; inline int read(){ int X=0,w=0; char ch=0; while(!isdigit(ch)) {w|=ch=='-';ch=getchar();} while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar(); return w?-X:X; } inline void write(int x){ if(x<0) putchar('-'),x=-x; if(x>9) write(x/10); putchar(x%10+'0'); } int dp[100001],sum[100001]; signed main(){ int n=read(),x=read(),y=read(); for(int i=1;i<=n;i++){ if(i!=y) dp[i]=1; else dp[i]=0; } for(int i=1;i<=x;i++){ int l=1,r=i/2; l=max(l,i-n); r=min(r,i); dp[i]=(dp[i]+sum[r]-sum[l-1]+mod)%mod; if(r>=i-y&&l<=i-y) dp[i]=(dp[i]-dp[i-y]+mod)%mod; sum[i]=(sum[i-1]+dp[i])%mod; } // for(int i=1;i<=x;i++) cout<<sum[i]<<" "; // cout<<endl; // for(int i=1;i<=x;i++) cout<<dp[i]<<" "; // cout<<endl; write(dp[x]); return 0; }