选课时间(题目已修改,注意读题)

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2137    Accepted Submission(s): 1699

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
对于每组输入数据,输出一个整数,表示学n个学分的组合数。
 
Sample Input
2
2 2
1 2
2 1
40 8
1 1
2 2
3 2
4 2
5 8
6 9
7 6
8 8
 
Sample Output
2
445
 
Author
xhd
 
Source
 
Recommend
lcy
 
 #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 选课时间(母函数)的更多相关文章

  1. HDU 2079 选课时间(普通型 数量有限 母函数)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2079 选课时间(题目已修改,注意读题) Time Limit:1000MS     Memory Li ...

  2. hdu 2079 选课时间

    hdu 2079 选课时间 题意:选的学分总和为n,并且学分为a的课有b种,总共有K(1<=k<=8)种学分不同的课,并且要选的学分最多为40:问选课方案有多少种?(学分相同的课即认为相同 ...

  3. hdu 2079 选课时间_母函数

    题意:需要学够n学分,有k个情况(x学分,y个相同学分的课) 解法:套母函数模板 #include <iostream> #include<cstdio> using name ...

  4. HDU 2079 选课时间(母函数模板题)

    链接:传送门 思路:母函数模板题 /************************************************************************* > Fil ...

  5. hdu 2079 选课时间(题目已改动,注意读题) (母函数)

    代码: #include<cstdio> #include<cstring> using namespace std; int main() { int t; scanf(&q ...

  6. HDU2079选课时间(母函数)

    母函数的简单应用http://acm.hdu.edu.cn/showproblem.php?pid=2079 介绍见另一篇随笔HDU1028Ignatius and the Princess III( ...

  7. 【hdoj_2079】选课时间(母函数)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=2079 此题采用母函数的知识求解,套用母函数模板即可: http://blog.csdn.net/ten_s ...

  8. 杭电ACM hdu 2079 选课时间 (模板)

    Problem Description 又到了选课的时间了,xhd看着选课表发呆,为了想让下一学期好过点,他想知道学n个学分共有多少组合.你来帮帮他吧.(xhd认为一样学分的课没区别) Input输入 ...

  9. hdu 2079 选课时间(题目已修改,注意读题)

    http://acm.hdu.edu.cn/showproblem.php?pid=2079 背包 #include <cstdio> #include <cstring> # ...

随机推荐

  1. DevExpress 关于 GridView 表格编辑中 点击其他按钮里导致 值未取到处理

    只需要给添加以下代码 在执行其他按钮前调 用一下 就可以了:主要是用来关闭编辑以及更新当前行编辑内容 this.gridControl1.FocusedView.CloseEditor(); this ...

  2. Wordpress模板标签大全

    Wordpress模板基本文件 style.css 样式表文件 index.php 主页文件 single.php 日志单页文件 page.php 页面文件 archvie.php 分类和日期存档页文 ...

  3. Eclipse 4.6 Neon, could not create the java virtual machine

    下了eclipse 4.6,打开报错:could not create the java virtual machine. a fatal exception has occurred. 命令行用 e ...

  4. 浅析python的string.Template

    摘自:python参考手册. string模块定义了一种新字符串类型Template,简化了特定的字符串置换操作, Template定义一个类 1.template(s),  #s是字符串 s='he ...

  5. hdu 2425 Hiking Trip

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2425 Hiking Trip Description Hiking in the mountains ...

  6. 九度oj 1348 数组中的逆序对

    原题链接:http://ac.jobdu.com/problem.php?pid=1348 归并排序求逆序对... #include<algorithm> #include<iost ...

  7. XAML特殊字符

    此部分只限制在XAML中,代码中不受此类限制. 1.特殊字符转义 XAML 特殊字符转义 特殊字符 转义 小于号 < < 大于号 > > 取址符 & & 引号 ...

  8. Go channel同步

    我们可以使用Channel来同步不同goroutines的执行.看下面的代码: package main import "fmt" import "time" ...

  9. @property @synthesize的含义以及误区。

    @property的作用是定义属性,声明getter,setter方法.(注意:属性不是变量) @synthesize的作用是实现属性的,如getter,setter方法. 在声明属性的情况下如果重写 ...

  10. quartz 数据表字典

    首次整理,可能有错误,还有少许的未整理,希望看到的人能给点补充(包括指点错误) 表名 表说明 自定义触发器 QRTZ_BLOB_TRIGGERS 列名(英) 列名(中) 数据类型 列长度 是否为空 列 ...