标签:style blog os strong io 2014 for re
#include<stdio.h> int p[1008],w[1008]; int dp[10000]; int min(int a,int b) {return a>b?b:a;} int main() { int E,F,V,T,i,j,N; scanf("%d",&T); while(T--) { scanf("%d%d",&E,&F); V=F-E; for(i=0;i<=V;i++) dp[i]=9999999; dp[0]=0; scanf("%d",&N); for(i=0;i<N;i++) scanf("%d%d",&p[i],&w[i]); for(i=0;i<N;i++) for(j=w[i];j<=V;j++) dp[j]=min(dp[j],dp[j-w[i]]+p[i]); if(dp[V]==9999999)printf("This is impossible.\n"); else printf("The minimum amount of money in the piggy-bank is %d.\n", dp[V]); } return 0; }
hdu 1114 Piggy-Bank,布布扣,bubuko.com
标签:style blog os strong io 2014 for re
原文地址:http://blog.csdn.net/lihaogegehuting/article/details/38130749