#include<cstdio> using namespace std; #define MOD 1004535809 int a[8001],f[1001][101],n,m,x,S; int main() { scanf("%d%d%d%d",&n,&m,&x,&S); for(int i=1;i<=S;++i) { scanf("%d",&a[i]); a[i]%=m; ++f[1][a[i]]; } for(int i=1;i<n;++i) for(int j=0;j<m;++j) for(int k=1;k<=S;++k) f[i+1][j*a[k]%m]=(f[i+1][j*a[k]%m]+f[i][j])%MOD; printf("%d\n",f[n][x]); return 0; }
时间: 2024-10-09 08:54:41