标签:could nsis osi for eval moment nes family input
Value | Annual interest |
4000 3000 |
400 250 |
Input
Output
Sample Input
1
10000 4
2
4000 400
3000 250
Sample Output
14050
解题思路:0/1背包
1 #include <iostream>
2 #include <stdio.h>
3 #include <string.h>
4 using namespace std;
5
6
7 int dp[200100];
8 int main()
9 {
10 int N;
11 scanf("%d",&N);
12 while(N--)
13 {
14
15 int v[1000],w[1000];
16 int am,n,nx;
17 scanf("%d %d",&am,&n);
18 scanf("%d",&nx);
19 for(int i = 1;i <= nx;i++)
20 {
21 scanf("%d %d",&v[i],&w[i]);
22 v[i]/=1000;
23 }
24 int m;
25 for(int k = 1;k <= n;k++)
26 {
27 memset(dp,0,sizeof(dp));
28 m= am/1000;
29 for(int i =1;i <= nx;i++)
30 {
31 for(int j = 0;j <=m;j++)
32 {
33 if(j-v[i]>=0)
34 dp[j] = max(dp[j-v[i]]+w[i],dp[j]);
35 }
36 }
37 am += dp[m];
38
39 }
40 cout<<am<<endl;
41 }
42
43
44 return 0;
45 }
标签:could nsis osi for eval moment nes family input
原文地址:http://www.cnblogs.com/a2985812043/p/7375776.html