解题报告:最多有8种学分的课,然后每种学分的课最多有10门,问要选学分为n的课一共有多少种选法,注意学分相同的课之间没有区别。

这题暴力可过,我用了8层循环,就简单了。听说可以用母函数,但没学过,看一下。

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
int score[];
int main() {
int T,n,k,x,y;
scanf("%d",&T);
while(T--) {
scanf("%d%d",&n,&k);
memset(score,,sizeof(score));
while(k--) {
scanf("%d%d",&x,&y);
score[x] = y;
}
int tot = ;
for(int a = ;a<=score[]&&a<=n;++a)
for(int b = ;b<=score[]&&a+*b<=n;++b)
for(int c = ;c<=score[]&&a+*b+*c<=n;++c)
for(int d = ;d<=score[]&&a+*b+*c+*d<=n;++d)
for(int e = ;e<=score[]&&a+*b+*c+*d+*e<=n;++e)
for(int f = ;f<=score[]&&a+*b+*c+*d+*e+*f<=n;++f)
for(int g = ;g<=score[]&&a+*b+*c+*d+*e+*f+*g<=n;++g)
for(int h = ;h<=score[]&&a+*b+*c+*d+*e+*f+*g+*h<=n;++h)
if(a+*b+*c+*d+*e+*f+*g+*h == n)
tot++;
printf("%d\n",tot);
}
return ;
}

HDU 2079 选课时间 组合题的更多相关文章

  1. hdu 2079 选课时间

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

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

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

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

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

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

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

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

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

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

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

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

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

  8. HDOJ 2079 选课时间(母函数)

    选课时间(题目已修改,注意读题) Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  9. HDU 2078 选课时间( 水题 )

    链接:传送门 思路:水题略 /************************************************************************* > File N ...

随机推荐

  1. Flyway的第一次认识

    1.  引言 想到要管理数据库的版本,是在实际产品中遇到问题后想到的一种解决方案,当时各个环境的数据库乱作一团,没有任何一个人(开发.测试.维护人员)能够讲清楚当前环境下的数据库是哪个版本,与哪个版本 ...

  2. Acdream1311_Apple

    无聊的时候看到上一次acdream群赛的一个题目,中间居然是有alice和bob的博弈题目,于是就去做了. 给n,m,两人轮流操作,每次操作可以使n+1,或者m+1,谁操作后满足nm>=A,那么 ...

  3. HashMap的put方法返回值问题

    API文档中的描述: 先看一个例子 Map<Character, Integer> map = new HashMap<Character, Integer>(); Syste ...

  4. Spring、MyBatis和SpringMVC整合的jar包下载

    spring mvc的jar包下载:http://repo.springsource.org/libs-release-local/org/springframework/spring/我下载的5.0 ...

  5. IbatisNet连接oracle 报错

    提示什么 connect oracle   1.5.0.xxxx 将你本机的oracle 客户端版本重装换成32位即可

  6. Atcoder Yahoo Programming Contest 2019 简要题解

    A-C 直接放代码吧. A int n,k; int main() { n=read();k=read(); puts(k<=(n+1)/2?"YES":"NO&q ...

  7. 【bzoj2002】 Hnoi2010—Bounce 弹飞绵羊

    http://www.lydsy.com/JudgeOnline/problem.php?id=2002 (题目链接) 题意 数轴上${n}$个点,每个点有一个权值${a_i}$,如果到达这个点,接下 ...

  8. kindeditor<=4.1.5上传漏洞复现

    0x00 漏洞描述 漏洞存在于kindeditor编辑器里,你能上传.txt和.html文件,支持php/asp/jsp/asp.net,漏洞存在于小于等于kindeditor4.1.5编辑器中 这里 ...

  9. Windows Shell远程执行代码漏洞((CVE-2018-8414)复现

    0x00   SettingContent-ms文件介绍 .SettingContent-ms是在Windows 10中引入的一种文件类型,它的内容是XML格式进行编写的,主要用于创建Windows设 ...

  10. pg中删除的页是否仍被访问

    昨天看到微信群中,有人提问:pg对于标记为删除的页,是否会扫描到? 今天做了一下测试,发现如果删除的是表的最后连续的几个页(根据ctid来确定数据插入先后,只讨论有insert的情况)中的数据,最后几 ...