标签:lan == pid name else print amount namespace mount
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1114
题目描述:
代码实现:
1 #include<cstdio> 2 #include<iostream> 3 using namespace std; 4 int dp[1000005]; 5 int main() 6 { 7 int w[500],p[500]; 8 int T,n,E,F,weight,i,j; 9 scanf("%d",&T); 10 while(T--){ 11 scanf("%d%d",&E,&F); 12 weight=F-E; 13 for(i=0;i<=weight;i++) 14 dp[i]=10000000; 15 scanf("%d",&n); 16 for(i=0;i<n;i++){ 17 scanf("%d%d",&p[i],&w[i]); 18 } 19 dp[0]=0; 20 for(i=0;i<n;i++){ 21 for(j=w[i];j<=weight;j++){ 22 dp[j]=min(dp[j],dp[j-w[i]]+p[i]); 23 } 24 } 25 if(dp[weight]==10000000) 26 printf("This is impossible.\n"); 27 else 28 printf("The minimum amount of money in the piggy-bank is %d.\n",dp[weight]); 29 } 30 return 0; 31 }
标签:lan == pid name else print amount namespace mount
原文地址:https://www.cnblogs.com/LJHAHA/p/10051131.html