提交时间:2022-05-04 22:08:10

运行 ID: 49231

#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][20005]; 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(); f[2][Pow(k1,n+1)+Pow(k1,n-1)*k2+20000]=1; for(int i=3;i<=n+1;i++) for(int j=-20000;j<=20000;j++) for(int k=-K;k<=K;k++) if(-20000<=j-f(k,i)&&j-f(k,i)<=20000) f[i][j+20000]+=f[i-1][j-f(k,i)+20000],f[i][j]%=mod; printf("%lld\n",f[n+1][k2+20000]); return 0; }