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的更多相关文章

  1. 机器学习实战二:波士顿房价预测 Boston Housing

    波士顿房价预测 Boston housing 这是一个波士顿房价预测的一个实战,上一次的Titantic是生存预测,其实本质上是一个分类问题,就是根据数据分为1或为0,这次的波士顿房价预测更像是预测一 ...

  2. 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 ...

  3. [ An Ac a Day ^_^ ] UVALive 2635 Housing Complexes 二分图最大匹配

    快要比赛了 看看原来做过的题 感觉这道题当时做的还是挺费劲的 所以发一下 题意: 一个土豪要建别墅 因为有的地区地方不够大 所以要拆屋子 每个地方的字母就是对应开发商的地盘 没有字母的就是自由土地 一 ...

  4. HDU 2426 Interesting Housing Problem (最大权完美匹配)【KM】

    <题目链接> 题目大意: 学校里有n个学生和m个公寓房间,每个学生对一些房间有一些打分,如果分数为正,说明学生喜欢这个房间,若为0,对这个房间保持中立,若为负,则不喜欢这个房间.学生不会住 ...

  5. HDU 2426 Interesting Housing Problem(二分图最佳匹配)

    http://acm.hdu.edu.cn/showproblem.php?pid=2426 题意:每n个学生和m个房间,现在要为每个学生安排一个房间居住,每个学生对于一些房间有一些满意度,如果满意度 ...

  6. HDU2426:Interesting Housing Problem(还没过,貌似入门题)

    #include <iostream> #include <queue> #include <stdio.h> #include <string.h> ...

  7. Sberbank Russian Housing Market比赛总结

    第一次真正意义上参加kaggle比赛,都是工作之余看看别人的kernel,然后整理整理自己的分析代码. 总体来说,本次比赛对我而言更像一个入门比赛,更多的是走走kaggle比赛的整个流程,看看高手们都 ...

  8. advanced regression to predict housing prices

    https://docs.google.com/presentation/d/e/2PACX-1vQGlXP6QZH0ATzXYwnrXinJcCn00fxCOoEczPAXU-n3hAPLUfMfi ...

  9. [Hands-on-Machine-Learning-master] 02 Housing

    用到的函数 numpy.random.permutation随机排列一个序列,返回一个排列的序列. >>> np.random.permutation(10) array([1, 7 ...

随机推荐

  1. angularJS1笔记-(4)-自定义服务

    html: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  2. KEIL C51 printf格式化输出特殊用法

    作者:dragoniye   发布:2014-02-15 12:44   分类:硬件     抢沙发   /*******************************************KEI ...

  3. n位格雷曼实现

    参考: 格雷码的实现 问题:产生n位元的所有格雷码.   格雷码(Gray Code)是一个数列集合,每个数使用二进位来表示,假设使用n位元来表示每个数字,任两个数之间只有一个位元值不同. 例如以下为 ...

  4. PAT 甲级 1150 Travelling Salesman Problem

    https://pintia.cn/problem-sets/994805342720868352/problems/1038430013544464384 The "travelling ...

  5. 一文总结之Redis

    目录 Redis 目标 Redis简介 什么是Redis 特性 Redis当前应用情况 安装 基本使用 键 exists判断键存在性.del删除键.type键类型 expire key的时效性设置 基 ...

  6. ZOJ3435_Ideal Puzzle Bobble

    把L,H,W分别减一就变成上面一个题目了. 不多说,也不召唤代码君了.

  7. python的N个小功能(图片预处理:打开图片,滤波器,增强,灰度图转换,去噪,二值化,切割,保存)

    ############################################################################################# ###### ...

  8. 【bzoj5166】[HAOI2014]遥感监测 贪心

    题目描述 给出平面上 $n$ 个圆,在x轴上选出尽可能少的点,使得每个圆中至少有一个点.求这个最小点数. 输入 第1行: N R 分别表示激光点的个数和射电望远镜能检测到的半径 第2~N+1行: Xi ...

  9. png?wxfrom=5&wx_lazy=1

    作为一名游戏行业的视频&平面设计师,平时的工作就是为公司发行的游戏制作宣传视频.广告.平面宣传图,打交道最多的自然就是Adobe家族的设计软件,Photoshop.AfterEffects.P ...

  10. GreatSct -应用程序白名单bypass工具

      0x00 GreatSCT简介 GreatSCT目前得到了@ConsciousHacker的支持,该项目名为Great SCT(Great Scott).Great SCT是一个用于生成应用程序白 ...