HDOJ 2079 选课时间(母函数)
选课时间(题目已修改,注意读题)
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2137 Accepted Submission(s): 1699
每组数据的第一行是两个整数n(1 <= n <= 40),k(1 <= k <= 8)。
接着有k行,每行有两个整数a(1 <= a <= 8),b(1 <= b <= 10),表示学分为a的课有b门。
2 2
1 2
2 1
40 8
1 1
2 2
3 2
4 2
5 8
6 9
7 6
8 8
445
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int a[],b[];
int c1[],c2[]; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n,m; scanf("%d%d",&m,&n); memset(a,,sizeof(a));
memset(b,,sizeof(b));
memset(c1,,sizeof(c1));
memset(c2,,sizeof(c2)); for(int i=;i<=n;i++)
{
scanf("%d%d",&a[i],&b[i]);
} for(int i=,s=;s<=b[];i+=a[],s++)
{
c1[i]=;
} for(int i=;i<=n;i++)
{
for(int j=;j<=m;j++)
{
for(int k=,s=;k+j<=m&&s<=b[i];k+=a[i],s++)
c2[k+j]+=c1[j];
} for(int j=;j<=m;j++)
{
c1[j]=c2[j];
c2[j]=;
}
} printf("%d\n",c1[m]); }
return ;
}
HDOJ 2079 选课时间(母函数)的更多相关文章
- HDU 2079 选课时间(普通型 数量有限 母函数)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2079 选课时间(题目已修改,注意读题) Time Limit:1000MS Memory Li ...
- hdu 2079 选课时间
hdu 2079 选课时间 题意:选的学分总和为n,并且学分为a的课有b种,总共有K(1<=k<=8)种学分不同的课,并且要选的学分最多为40:问选课方案有多少种?(学分相同的课即认为相同 ...
- hdu 2079 选课时间_母函数
题意:需要学够n学分,有k个情况(x学分,y个相同学分的课) 解法:套母函数模板 #include <iostream> #include<cstdio> using name ...
- HDU 2079 选课时间(母函数模板题)
链接:传送门 思路:母函数模板题 /************************************************************************* > Fil ...
- hdu 2079 选课时间(题目已改动,注意读题) (母函数)
代码: #include<cstdio> #include<cstring> using namespace std; int main() { int t; scanf(&q ...
- HDU2079选课时间(母函数)
母函数的简单应用http://acm.hdu.edu.cn/showproblem.php?pid=2079 介绍见另一篇随笔HDU1028Ignatius and the Princess III( ...
- 【hdoj_2079】选课时间(母函数)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2079 此题采用母函数的知识求解,套用母函数模板即可: http://blog.csdn.net/ten_s ...
- 杭电ACM hdu 2079 选课时间 (模板)
Problem Description 又到了选课的时间了,xhd看着选课表发呆,为了想让下一学期好过点,他想知道学n个学分共有多少组合.你来帮帮他吧.(xhd认为一样学分的课没区别) Input输入 ...
- hdu 2079 选课时间(题目已修改,注意读题)
http://acm.hdu.edu.cn/showproblem.php?pid=2079 背包 #include <cstdio> #include <cstring> # ...
随机推荐
- desin pattern
uml tool http://cruise.site.uottawa.ca/umple/ http://www.umldesigner.org/download/ http://www.eclips ...
- Oracle 将普通表转换为分区表
DB:11.2.0.30 将普通表转换为区分表 一.利用原表重建分区表SQL>create table yoon ( id number primary key ,time date ); Ta ...
- arcgis中使用excel中x,y坐标创建点问题
文件——从x,y中添加,可以显示点的位置 右击图层导出数据时,出现无法绘制图形,生成shapefile文件的情况.经过排除数据发现 当x,y坐标值中出现null等异常值时,会出现上述无法导出的情况.
- Android--将图片存放到我们本地
代码里面有详细的解释,我就不多说了 //处理并保存图像 private File dealPhoto(Bitmap photo){ FileOutputStream fileOutputStream ...
- IOS中 如何去除Tabview里面cell之间的下划线
可以利用Tabview的separatorStyle属性来设置,选择其中的UITableViewCellSeparatorStyleNone 即可去除cell之间的下划线 self.tableView ...
- SQL开发技巧(二) 【转】感觉他写的很好
本文转自: http://www.cnblogs.com/marvin/p/DevelopSQLSkill_2.html 本系列文章旨在收集在开发过程中遇到的一些常用的SQL语句,然后整理归档,本系列 ...
- Object-c 语法 - NSObject常用方法和反射
NSObject常用方法 - (BOOL)isKindOfClass:(Class)aClass //判断是否为aClass或者aClass的子类的实例,aClass可以通过[类名 class]获取 ...
- [转]insmod
[转]insmod http://www.cnblogs.com/amaoxiaozhu/archive/2013/03/08/2950002.html 在Linux下,驱动程序是内核的一部分,运行在 ...
- STM32管教复用与重映射关系
摘自:http://blog.csdn.net/lincheng15/article/details/51789093 概括一下:复用就是一个引脚有几个功能,1.做普通IO输入输出 2.其他外设的输入 ...
- 67.ARP协议
ARP是地址解析协议Address Resolution Protocol的缩写.是一个位于TCP/IP协议栈中的低层协议,负责将某个IP地址解析程对应的MAC地址.在局域网中,网络实际传输的是“帧” ...