Lightoj 1232-coin Change (II) "Full backpack"

Source: Internet
Author: User



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",&amp;t);
for (int ca = 1; ca <= t; ca++)
{
scanf("%d%d",&amp;n,&amp;k);
for (int i = 0; i < n; i++)
scanf("%d",&amp;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"


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.