标签:blog http io ar os sp for 数据 div
4 12 10 7 5 1
2
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<string> #include<cmath> #include<algorithm> using namespace std; const int maxn=100010; int n,m,dp[maxn],c; int main() { while(scanf("%d%d",&n,&m)!=EOF) { if(n==0&&m==0) break; for(int i=1;i<=m;i++) dp[i]=0x3fff; for(int i=1;i<=n;i++) { scanf("%d",&c); for(int j=c;j<=m;j++) dp[j]=min(dp[j],dp[j-c]+1); } printf("%d\n",dp[m]); } return 0; }
标签:blog http io ar os sp for 数据 div
原文地址:http://www.cnblogs.com/a972290869/p/4099746.html