标签:style nbsp define bzoj scan max challenge div main
dp好厉害啊。。。。。要多练才行。
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define maxn 2050 using namespace std; int n,m,f[maxn][maxn],w[maxn],c[maxn][maxn]; int main() { scanf("%d%d",&n,&m); for (int i=1;i<=n;i++) scanf("%d",&w[i]); f[0][0]=1; for (int i=1;i<=n;i++) for (int j=0;j<=m;j++) { f[i][j]=f[i-1][j]; if (j>=w[i]) f[i][j]=(f[i][j]+f[i-1][j-w[i]])%10; } for (int i=1;i<=n;i++) for (int j=0;j<=m;j++) { if (j==0) c[i][j]=1; else if (j<w[i]) c[i][j]=f[n][j]; else c[i][j]=(f[n][j]-c[i][j-w[i]]+10)%10; } for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) printf("%d",c[i][j]%10); printf("\n"); } return 0; }
标签:style nbsp define bzoj scan max challenge div main
原文地址:http://www.cnblogs.com/ziliuziliu/p/6009434.html