提交时间:2022-05-09 13:03:26

运行 ID: 49486

#include <bits/stdc++.h> using namespace std; int n,K,k1,k2; int f[55][40010]; const int Mod=998244353; int Pow(int x,int k) { long long tmp=1; while(k) { if(k & 1) tmp=tmp*x%11; x=x*x%11; k/=2; } return (tmp+11)%11; } int main() { cin>>n>>K>>k1>>k2; long long rec=n*10*K; f[2][Pow(k1,n)*k1+Pow(k1,n-1)*k2+rec]=1; for(int i=3; i<=n+1; i++) { long long a=Pow(k1,n-i+1)%11; for(int j=-rec; j<=rec; j++) { for(int k=-K; k<=K; k++) if(j-a*k+rec>=0) { f[i][j+rec]+=f[i-1][j-a*k+rec]; f[i][j+rec]%=Mod; } } } cout<<f[n+1][k2+rec]%Mod<<'\n'; return 0; }