题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1114
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=10000+5;
const int INF=0x3f3f3f3f;
int d[maxn];
int main()
{int T,lW,NW,W,n,v,w; cin>>T;while(T--){cin>>lW>>NW;W=NW-lW;cin>>n;memset(d,INF,sizeof(d));d[0]=0;for(int i=1;i<=n;i++){scanf("%d%d",&v,&w);if(w>W) continue;for(int j=w;j<=W;j++)d[j]=min(d[j],d[j-w]+v);}if(d[W]==INF) cout<<"This is impossible."<<endl;else printf("The minimum amount of money in the piggy-bank is %d.\n",d[W]);}return 0;
}