HDU 2079 选课时间 组合题
解题报告:最多有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 选课时间 组合题的更多相关文章
- hdu 2079 选课时间
hdu 2079 选课时间 题意:选的学分总和为n,并且学分为a的课有b种,总共有K(1<=k<=8)种学分不同的课,并且要选的学分最多为40:问选课方案有多少种?(学分相同的课即认为相同 ...
- HDU 2079 选课时间(普通型 数量有限 母函数)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2079 选课时间(题目已修改,注意读题) Time Limit:1000MS Memory Li ...
- hdu 2079 选课时间(题目已修改,注意读题)
http://acm.hdu.edu.cn/showproblem.php?pid=2079 背包 #include <cstdio> #include <cstring> # ...
- HDU 2079 选课时间(母函数模板题)
链接:传送门 思路:母函数模板题 /************************************************************************* > Fil ...
- hdu 2079 选课时间(题目已改动,注意读题) (母函数)
代码: #include<cstdio> #include<cstring> using namespace std; int main() { int t; scanf(&q ...
- 杭电ACM hdu 2079 选课时间 (模板)
Problem Description 又到了选课的时间了,xhd看着选课表发呆,为了想让下一学期好过点,他想知道学n个学分共有多少组合.你来帮帮他吧.(xhd认为一样学分的课没区别) Input输入 ...
- hdu 2079 选课时间_母函数
题意:需要学够n学分,有k个情况(x学分,y个相同学分的课) 解法:套母函数模板 #include <iostream> #include<cstdio> using name ...
- HDOJ 2079 选课时间(母函数)
选课时间(题目已修改,注意读题) Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 2078 选课时间( 水题 )
链接:传送门 思路:水题略 /************************************************************************* > File N ...
随机推荐
- cmd命令行安装,删除Windows证书(certgmr的简单使用)
在管理证书的时候需要用到certmgr工具. 在cmd中执行certmgr会弹出证书管理的工具,但是不能用命令行去管理证书,需要额外的工具 cermgr.exe:下载链接 https://pan.ba ...
- pygame学习笔记(3)——时间、事件、文字
转载请注明:@小五义 http://www.cnblogs.com/xiaowuyi 1.运动速率 上节中,实现了一辆汽车在马路上由下到上行驶,并使用了pygame.time.delay(200 ...
- office2013 激活方法
1.秘钥码激活 可以淘宝上买一个. 2.KMS激活软件激活 帖子地址 http://tieba.baidu.com/p/3855281630 Office 2013 Professional Plus ...
- 2013南京网赛1003 hdu 4750 Count The Pairs
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4750 题意:给出一个无向图,f(a,b)表示从点a到点b的所有路径中的每条路径的最长边中的最小值,给出 ...
- 内存映像分析工具Eclipse Memory Analyzer
1. Eclipse Memory Analyzer安装 Help ->Eclipse Marketplace,搜索Memory,点击install,->confirm->同意证书内 ...
- Executors提供的四种线程池和自定义线程池
JAVA并发编程——EXECUTORS 线程池的思想是一种对象池的思想,开放一块内存空间,里面存放了众多(未死亡)的线程,池中线程执行调度由池管理器来处理.当有线程任务时,从池中取一个,执行完毕,对象 ...
- BZOJ3142 [Hnoi2013]数列 【组合数学】
题目链接 BZOJ3142 题解 题意:选一个正整数和\(K - 1\)个\([1,M]\)中的数,使得总和小于等于\(N\),求方案数模\(P\) 题目中\(K(M - 1) < N\)的限制 ...
- Linux内核设计与实现第十周读书笔记
第十七章 设备与模块 关于设备驱动与设备管理,我们讨论四种内核成分. 设备类型 模块 内核对象 sysfs 17.1设备类型 在Linux以及所有Unix系统中,设备被分为以下三种类型: 块设备,块设 ...
- bzoj 3853 : GCD Array
搬运题解Claris:1 n d v相当于给$a[x]+=v[\gcd(x,n)=d]$ $\begin{eqnarray*}&&v[\gcd(x,n)=d]\\&=& ...
- PyQt5整体介绍
1 PyQt5整体介绍 PyQt5是基于图形程序框架Qt5的Python语言实现,由一组Python模块构成. PyQt5的官方网站是:www.riverbankcomputing.co.uk. Py ...