Problem Description 又到了选课的时间了,xhd看着选课表发呆,为了想让下一学期好过点,他想知道学n个学分共有多少组合.你来帮帮他吧.(xhd认为一样学分的课没区别) Input输入数据的第一行是一个数据T,表示有T组数据.每组数据的第一行是两个整数n(1 <= n <= 40),k(1 <= k <= 8).接着有k行,每行有两个整数a(1 <= a <= 8),b(1 <= b <= 10),表示学分为a的课有b门. Output对于每…
hdu 2079 选课时间 题意:选的学分总和为n,并且学分为a的课有b种,总共有K(1<=k<=8)种学分不同的课,并且要选的学分最多为40:问选课方案有多少种?(学分相同的课即认为相同) 解法1:朴素背包 求解不重复子结构问题 原本认为只要在完全背包和01背包中把循环do式改成f[v]+=f[v-w]即可,但是发现很多重叠部分:给组小数据就会发现了: 3 3 1 2 2 3 3 3 原本f[1]只有1中,但是在二进制中,开始k = 1,f[1] += f[0],f[1]就等于1了,之后循环…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2079 选课时间(题目已修改,注意读题) Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description 又到了选课的时间了,xhd看着选课表发呆,为了想让下一学期好过点,他想知道学n个学分共有多少组合.你来帮帮他吧.(xhd认为一样学分的课没区别)   Inp…
http://acm.hdu.edu.cn/showproblem.php?pid=2079 背包 #include <cstdio> #include <cstring> #include <algorithm> #define maxn 3000 using namespace std; int dp[maxn]; int a,b; int t,n,k; int main() { scanf("%d",&t); while(t--) {…
链接:传送门 思路:母函数模板题 /************************************************************************* > File Name: 3.cpp > Author: WArobot > Blog: http://www.cnblogs.com/WArobot/ > Created Time: 2017年04月22日 星期六 21时55分43秒 ********************************…
题意:需要学够n学分,有k个情况(x学分,y个相同学分的课) 解法:套母函数模板 #include <iostream> #include<cstdio> using namespace std; int main(int argc, char** argv) { int i,j,k,t,sum; int c1[10000],c2[10000],num[120],n,m,x[120],y[120]; scanf("%d",&t); while(t--){…
解题报告:最多有8种学分的课,然后每种学分的课最多有10门,问要选学分为n的课一共有多少种选法,注意学分相同的课之间没有区别. 这题暴力可过,我用了8层循环,就简单了.听说可以用母函数,但没学过,看一下. #include<cstdio> #include<cstring> #include<iostream> #include<cmath> using namespace std; ]; int main() { int T,n,k,x,y; scanf(…
Problem Description People in Silverland use square coins. Not only they have square shapes but also their values are square numbers. Coins with values of all square numbers up to 289 (=17^2), i.e., 1-credit coins, 4-credit coins, 9-credit coins, ...…
代码: #include<cstdio> #include<cstring> using namespace std; int main() { int t; scanf("%d",&t); while(t--) { int n,k; int a[9],b[9]; scanf("%d%d",&n,&k); for(int i=1; i<=k; i++) { scanf("%d%d",&…
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY…