提交时间:2022-04-12 13:06:07
运行 ID: 48369
#include<bits/stdc++.h> using namespace std; inline long long read() { int x=0,f=1; char t=getchar(); while(t<'0'||t>'9'){if(t=='-')f=0;t=getchar();} while(t>='0'&&t<='9')x=(x<<1)+(x<<3)+(t^48),t=getchar(); return f?x:-x; } long long n,K,k1,k2,f[55][30]; int main() { n=read(),K=read(),k1=read(),k2=read(); f[1][k1%11]=1; f[2][(k1+k2)%11]=1; for(int i=1;i<=n+1;i++) for(long long k=-K;k<=K;k++) for(long long o=0;o<=k2;o++) { if(o>pow(k1,n-i+1))f[i][o%11]+=f[i-1][int(o-pow(k1,n-i+1)*k)%11]; } cout<<f[n+1][k2%11]; return 0; }