题解:
dp
f[i][j]表示前i个,膜为j
最后记得判断0
代码:
#include<bits/stdc++.h> using namespace std; const int N=2005; int n,m,a[N],f[N][N]; int main() { scanf("%d%d",&n,&m); for (int i=1;i<=n;i++)scanf("%d",&a[i]),a[i]%=m; f[0][0]=1;int k=1e8; for (int i=1;i<=n;i++) for (int j=0;j<m;j++) f[i][j]=(f[i-1][j]+f[i-1][(j-a[i]+m)%m])%k; printf("%d\n",(f[n][0]-1+k)%k); }