标签:des style blog io ar os sp for on
解题思路:直接套公式就可以做的完全背包。
#include<stdio.h> #include<string.h> int f[10010],a[4]; int max(int a,int b) { if(a>b) return a; else return b; } int main() { int ncase,i,v,n; while(scanf("%d",&ncase)!=EOF) { while(ncase--) { a[1]=150; a[2]=200; a[3]=350; memset(f,0,sizeof(f)); scanf("%d",&n); for(i=1;i<=3;i++) { for(v=a[i];v<=n;v++) f[v]=max(f[v],f[v-a[i]]+a[i]); } printf("%d\n",n-f[n]); } } }
标签:des style blog io ar os sp for on
原文地址:http://www.cnblogs.com/wuyuewoniu/p/4146417.html