#include <bits/stdc++.h> //从前往后
using namespace std;
const int maxn=1e4+5;
int T,n,V,v[maxn],w[maxn],dp[maxn];
int main(){
int i,j;
cin>>T;
n=3;
v[1]=w[1]=150;v[2]=w[2]=200;v[3]=w[3]=350;
while(T--){
scanf("%d",&V);
memset(dp,0,sizeof(dp));
for(i=1;i<=n;i++){
for(j=w[i];j<=V;j++){
dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
}
}
int ans=0;
for(i=1;i<=V;i++){
if(ans<dp[i]){
ans=dp[i];
}
}
cout<<V-ans<<endl;
}
}
hdu1248可重复取(从前往后)要遍历求max
最新推荐文章于 2024-08-08 15:12:59 发布