题目链接:https://www.tyvj.cn/Problem_Show.aspx?id=1015
完全背包
1 #include <cstdio> 2 #include <algorithm> 3 #include <cstring> 4 using namespace std; 5 int c[11],f[101]; 6 int main(void) { 7 freopen("in1.txt","r",stdin); 8 int n,i,j;for(i=1;i<=10;scanf("%d",c+i++)) 9 ;scanf("%d",&n); 10 for(i=1;i<=n;f[i++]=100000) 11 ; 12 for(i=1;i<=10;++i)for(j=i;j<=n;++j)f[j]=min(f[j],f[j-i]+c[i]); 13 printf("%d\n",f[n]); 14 return 0; 15 }
0x3f3f3f3f可以memset-_-#