提交时间:2022-05-05 13:13:18
运行 ID: 49261
#include <bits/stdc++.h> using namespace std; #define mod 998244353 inline int read(){ int x=0;bool f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=0;ch=getchar();} while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();} return f?x:-x; } int n,k1,k2,K; long long f[55][2505]; inline int Pow(int x,int y){ int res=1; while(y){ if(y&1) res=res*x%11; y>>=1; x=x*x%11; } return res; } #define f(x,y) (11+Pow(k1,n-y+1)%11)%11*x int main(){ n=read(),K=read(),k1=read(),k2=read(); int x=k*n*10; f[2][Pow(k1,n)*k1+Pow(k1,n-1)*k2+x]=1; for(int i=3;i<=n+1;i++) for(int j=-x;j<=x;j++) for(int k=-K;k<=K;k++) if(-x<=j-f(k,i)&&j-f(k,i)<=x) f[i][j+x]+=f[i-1][j-f(k,i)+x],f[i][j+x]%=mod; printf("%lld\n",f[n+1][k2+x]); return 0; }