提交时间:2022-04-14 09:43:27
运行 ID: 48613
#include<bits/stdc++.h> using namespace std; template<typename T>inline void in(T &a) { T ans=0,f=0; char c=getchar(); for(; c<'0' || c>'9'; f^=!(c^'-'),c=getchar()); for(; c<='9' && c>='0'; c=getchar())ans=(ans<<3)+(ans<<1)+(c^48); a=(f?~ans+1:ans); } template<typename T,typename... Args>inline void in(T &a,Args&...args){ in(a),in(args...); } int qpow(int a,int b,int ans=1){ while(b>=1){ if(b&1)ans=(ans*a)%11; a=(a*a)%11,b>>=1; } return ans; } int dp[55][25005],a[55],n,k,k1,k2,maxn,minn; int main(){ in(n,k,k1,k2); for(register int i=1;i<=n+1;i++)a[i]=qpow(k1,n-i+1); minn=maxn=k1*a[1]+k2*a[2]; for(register int i=minn+min(a[3],-a[3])*k;i<=maxn+max(a[3],-a[3])*k;i++)dp[3][i+12500]=1; for(register int i=3;i<=n+1;i++){ minn+=min(a[i],-a[i])*k,maxn+=max(a[i],-a[i])*k; for(register int m=minn;m<=maxn;m++){ for(register int n=min(-a[i+1],a[i+1])*k;n<=max(-a[i+1],a[i+1])*k;n++){ dp[i+1][m+n+12500]+=dp[i][m+12500],dp[i+1][m+n+12500]%=998244353; } } } printf("%d\n",dp[n+1][k2+12500]); return 0; }