提交时间:2024-01-02 13:42:44
运行 ID: 118924
#include<bits/stdc++.h> using namespace std; const int maxn=100010,mod=998244353; int sum[21][maxn],dp[21][maxn],n,x,y; int main(){ scanf("%d%d%d",&n,&x,&y); dp[0][0]=1; for(int i=0;i<=x;i++) sum[0][i]=1;//维护前缀和即[1~j-1] for(int i=1;i<=20;i++){ for(int j=1;j<=x;j++){ dp[i][j]=sum[i-1][j/2]; if(j>n)dp[i][j]=(dp[i][j]-sum[i-1][j-n-1]+mod)%mod; if(y>=j-j/2 && y<=j)dp[i][j]=(dp[i][j]-dp[i-1][j-y]+mod)%mod; sum[i][j]=(sum[i][j-1]+dp[i][j])%mod; } } int ans=0; for(int i=1;i<=20;i++) (ans+=dp[i][x])%=mod; printf("%d\n",ans); return 0; }