soj1564. HOUSING
1564. HOUSING
Constraints
Time Limit: 1 secs, Memory Limit: 32 MB
Description
For the Youth Olympic Games in Singapore, the administration is considering to house each team in several units with at least 5 people per unit. A team can have from 5 to 100 members, depending on the sport they do. For example, if there are 16 team members, there are 6 ways to distribute the team members into units: (1) one unit with 16 team members; (2) two units with 5 and 11 team members, respectively; (3) two units with 6 and 10 team members, respectively; (4) two units with 7 and 9 team members, respectively; (5) two units with 8 team members each; (6) two units with 5 team members each plus a third unit with 6 team members. This list might become quite lengthy for a large team size.
In order to see how many choices to distribute the team members there are, the administration would like to have a computer program that computes for a number n the number m(n) of possible ways to distribute the team members into the units allocated, with at least 5 people per unit. Note that equivalent distributions like 5 + 5 + 6, 5 + 6 + 5 and 6 + 5 + 5 are counted only once. So m(16) = 6 (as seen above), m(17) = 7 (namely 17, 5 + 12, 6 + 11, 7 + 10, 8 + 9, 5 + 5 + 7, 5 + 6 + 6) and m(20) = 13.
The computer program should read the number n and compute m(n).
Input
The input contains just one number which is the number n as described above, where 5 <= n <= 100.
Output
The output consists of a single line with an integer that is the number m(n) as specified above. As n is at most 100, one can estimate that m(n) has at most 7 decimal digits.
Sample Input
20
Sample Output
13
跟那个换零钱的动态规划差不多,但是这里硬币数是由5——n,因此改一改即可。
#include <iostream>
#include <memory.h>
using namespace std;
long long f[110];
int main()
{
int n;
while(cin >> n)
{
memset(f,0,sizeof(f));
int i;
f[0] = 1;
int j;
for(i = 5;i <= n;i++)
{
for(j = i;j <= n;j++)
f[j] += f[j-i];
}
cout << f[n] << endl;
}
return 0;
}
soj1564. HOUSING的更多相关文章
- 机器学习实战二:波士顿房价预测 Boston Housing
波士顿房价预测 Boston housing 这是一个波士顿房价预测的一个实战,上一次的Titantic是生存预测,其实本质上是一个分类问题,就是根据数据分为1或为0,这次的波士顿房价预测更像是预测一 ...
- hdu 2426 Interesting Housing Problem 最大权匹配KM算法
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2426 For any school, it is hard to find a feasible ac ...
- [ An Ac a Day ^_^ ] UVALive 2635 Housing Complexes 二分图最大匹配
快要比赛了 看看原来做过的题 感觉这道题当时做的还是挺费劲的 所以发一下 题意: 一个土豪要建别墅 因为有的地区地方不够大 所以要拆屋子 每个地方的字母就是对应开发商的地盘 没有字母的就是自由土地 一 ...
- HDU 2426 Interesting Housing Problem (最大权完美匹配)【KM】
<题目链接> 题目大意: 学校里有n个学生和m个公寓房间,每个学生对一些房间有一些打分,如果分数为正,说明学生喜欢这个房间,若为0,对这个房间保持中立,若为负,则不喜欢这个房间.学生不会住 ...
- HDU 2426 Interesting Housing Problem(二分图最佳匹配)
http://acm.hdu.edu.cn/showproblem.php?pid=2426 题意:每n个学生和m个房间,现在要为每个学生安排一个房间居住,每个学生对于一些房间有一些满意度,如果满意度 ...
- HDU2426:Interesting Housing Problem(还没过,貌似入门题)
#include <iostream> #include <queue> #include <stdio.h> #include <string.h> ...
- Sberbank Russian Housing Market比赛总结
第一次真正意义上参加kaggle比赛,都是工作之余看看别人的kernel,然后整理整理自己的分析代码. 总体来说,本次比赛对我而言更像一个入门比赛,更多的是走走kaggle比赛的整个流程,看看高手们都 ...
- advanced regression to predict housing prices
https://docs.google.com/presentation/d/e/2PACX-1vQGlXP6QZH0ATzXYwnrXinJcCn00fxCOoEczPAXU-n3hAPLUfMfi ...
- [Hands-on-Machine-Learning-master] 02 Housing
用到的函数 numpy.random.permutation随机排列一个序列,返回一个排列的序列. >>> np.random.permutation(10) array([1, 7 ...
随机推荐
- Beta阶段——第五篇 Scrum 冲刺博客
i. 提供当天站立式会议照片一张: ii. 每个人的工作 (有work item 的ID) (1) 昨天已完成的工作: 对宿舍权限的管理 (2) 今天计划完成的工作: 完善权限管理,进行舍员充值分明 ...
- Tomcat 总体结构
一.Tomcat 总体结构 1.Server(服务器)是Tomcat构成的顶级构成元素,所有一切均包含在Server中,Server的实现类StandardServer可以包含一个到多个Service ...
- Ubuntu和Windows相互共享文件夹
一.Ubuntu访问Windows共享文件夹 1.对需要共享文件夹右击->属性->共享 2.选择要与其共享的用户,选择好用户点击有点添加按钮添加,然后点击下方的共享按钮 3.完成共享 4. ...
- DAY3-Flask项目
1.jsonify: 得到了从API获得的数据并返回,API返回的json数据被转化成dict,我们还需要把dict序列化: return json.dump(result), 200, {'cont ...
- [SDOI2013]项链
description luogu 最近,铭铭迷恋上了一种项链.与其他珍珠项链基本上相同,不过这种项链的珠子却与众不同,是正三菱柱的泰山石雕刻而成的. 三菱柱的侧面是正方形构成的,上面刻有数字. 能够 ...
- HNOI2018毒瘤
题面链接 luogu sol 这篇博是骗访问量的QwQ. 考虑树怎么做,简单容斥.诸如\(f[u][0]=\prod (f[v][0]+f[v][1]),f[u][1]=\prod f[v][0]\) ...
- phpmyadmin 配置方法
几乎所有的配置参数都在 config.inc.php 文件中.如果这个文件不存在,您可以在 libraries 目录中找到 config.default.php,将它复制到根目录,并改名为 confi ...
- Java的I/O系统
1.File类 File类既能代表一个特定文件的名称,又能代表一个目录下的一组文件的名称. 如果我们调用不带参数的list()方法,便可以获得此File对象包含的全部列表.然而,如果我们想获得一个受限 ...
- win10不能被远程解决方案(开启远程桌面,防火墙仍不能被远程解决方案)
开启远程桌面,防火墙仍不能被远程解决方案 1.“Win+R”→“gpedit.msc” 2.依次展开“计算机配置”→“管理模版”→“系统”→“凭据分配”→找到“允许分配保存的凭据用于仅NTLM服务器身 ...
- Windows环境下,将Django部署到Apache Web Server
在Windows上部署Django(用mod_wsgi)会出现各种奇怪的问题,现简单记录下配置过程及遇到的错误及解决方法. 环境搭建 ...