Title Link: http://www.lightoj.com/volume_showproblem.php?problem=1232
Test instructions: The value of each item is val[i] (>=1), each item has k, comprising the number of schemes with a value of K. Full backpack.
Solution: Complete backpack count.
Code:
#include <stdio.h>
#include <ctime>
#include <math.h>
#include <limits.h>
#include <complex>
#include <string>
#include <functional>
#include <iterator>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <iostream>
#include <ctime>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <time.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
using namespace std;
Int n, K;
int val[110];
int dp[10100];
Int main ()
{
Int t;
scanf("%d",&t);
for (int ca = 1; ca <= t; ca++)
{
scanf("%d%d",&n,&k);
for (int i = 0; i < n; i++)
scanf("%d",&val[i]);
//Total bag count
memset(dp,0,sizeof(dp));
Dp[0] = 1;
for (int i = 0; i < n; i++)
for (int j = val[i]; j <= k; j++)
dp[j] = (dp[j] + dp[j-val[i]]) % 100000007;
printf("Case %d: %d\n",ca,dp[k]);
}
Return 0;
}
LightOJ 1232 - Coin Change
Lightoj 1232-coin Change (II) "Full backpack"