提交时间:2022-04-12 12:59:47
运行 ID: 48364
#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][3000]; int main() { n=read(),K=read(),k1=read(),k2=read(); f[1][(k1+110000)%11]=1; f[2][(k1+k2+110000)%11]=1; for(int i=1;i<=n+1;i++) for(int k=-K;k<=K;k++) for(int o=pow(k1,n-i+1)*k;o<=k2;o++) { f[i][(o+1100000)%11]+=f[i-1][int(o-pow(k1,n-i+1)*k+110000)%11]; } cout<<f[n+1][(k2+110000)%11]; return 0; }