题目

题意:给你一个数字n,求将其划分成若干个数字相加总共有多少种划分数;

<span style="font-size:24px;">#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
#define MM(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef unsigned long long ULL;
const int mod = 1000000007;
const double eps = 1e-10;
const int inf = 0x3f3f3f3f;
const int big=50000;
int max(int a,int b) {return a>b?a:b;};
int min(int a,int b) {return a<b?a:b;};
int dp[125][125];
//dp[i][j]=dp[i][j-1]+dp[i-j][j]
int main()
{
memset(dp,0,sizeof(dp));
for(int i=1;i<=120;i++)
for(int j=1;j<=120;j++)
if(j<i)
dp[i][j]=dp[i][j-1]+dp[i-j][j];
else if(j>i)
dp[i][j]=dp[i][i];
else if(i==j)
dp[i][j]=dp[i][j-1]+1;
int n;
while(cin>>n)
cout<<dp[n][n]<<endl;
return 0;
}
</span>

分析:dp;

核心代码:dp[i][j]=dp[i][j-1]+dp[i-j][j]

dp[i][j]代表第i个数划分数中最大不超过j的划分种类数

if(j>i)dp[i][j]=dp[i][i];

如果j==i;dp[i][j]=dp[i][j-1]+1;

if(j<i)   dp[i][j]=dp[i][j-1](没有j)+dp[i-j][j](有j,那么取出j,则剩余的划分数中最大也不

能超过j,所以是dp[i-j][j])

hdu 1208 Ignatius and the Princess III 划分数,dp的更多相关文章

  1. hdu 1028 Ignatius and the Princess III 简单dp

    题目链接:hdu 1028 Ignatius and the Princess III 题意:对于给定的n,问有多少种组成方式 思路:dp[i][j],i表示要求的数,j表示组成i的最大值,最后答案是 ...

  2. HDU 1028 Ignatius and the Princess III:dp or 母函数

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028 题意: 给你一个正整数n,将n拆分成若干个正整数之和,问你有多少种方案. 注:"4 = ...

  3. HDU 1028 Ignatius and the Princess III 整数的划分问题(打表或者记忆化搜索)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1028 Ignatius and the Princess III Time Limit: 2000/1 ...

  4. hdu 1028 Ignatius and the Princess III (n的划分)

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  5. hdu 1028 Ignatius and the Princess III(DP)

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  6. HDU 1028 Ignatius and the Princess III (母函数或者dp,找规律,)

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  7. hdu 1028 Ignatius and the Princess III 母函数

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  8. HDU 1028 Ignatius and the Princess III (递归,dp)

    以下引用部分全都来自:http://blog.csdn.net/ice_crazy/article/details/7478802  Ice—Crazy的专栏 分析: HDU 1028 摘: 本题的意 ...

  9. HDU 1028 Ignatius and the Princess III (生成函数/母函数)

    题目链接:HDU 1028 Problem Description "Well, it seems the first problem is too easy. I will let you ...

随机推荐

  1. 2016年蓝桥杯省赛C++A组 消除尾一

    消除尾一: 下面的代码把一个整数的二进制表示的最右边的连续的1全部变成0如果最后一位是0,则原数字保持不变. 如果采用代码中的测试数据,应该输出: 00000000000000000000000001 ...

  2. 计算机和python

    计算机基础知识 CPU 人类的大脑 运算和处理问题 内存 临时存储数据 断电就消失了 硬盘 永久 存储数据 操作系统是一个(特殊)的程序,调度硬件和软件之间的数据交互 python的应用和历史 IT, ...

  3. 【笔记】vue实现简单项目和页面跳转

    此项目适合不会前端,不会vue的人. 不会vue真正的开发,这里用vue和vant-ui简单搭一个商城app的tabbar和页面跳转. 装vue-cli3.0 根据官网快速上手搭建vant项目,官网 ...

  4. js中setTimeout和setInterval的应用方法(转)

    JS里设定延时: 使用SetInterval和设定延时函数setTimeout 很类似.setTimeout 运用在延迟一段时间,再进行某项操作. setTimeout("function& ...

  5. 105、Replicated Mode VS Global Mode (Swarm12)

    参考https://www.cnblogs.com/CloudMan6/p/8028712.html   Swarm 可以在 Service 创建和运行过程中灵活的通过 --replicas 调整容器 ...

  6. pl/sql 笔记之基础(上)

    由于公司中使用 oracle,而本人对存储过程一直也懵懵懂懂,故一周时间学习了一遍 pl/sql,在此记下笔记!!! 一.前提,pl/sql 是啥? 1.PL/SQL是一种高级数据库程序设计语言,该语 ...

  7. Mac 常用软件

    command+space开启新的一天 窗口管理:Magnet 写代码:Pycharm.vscode.sublime text 虚拟机:VMware Fusion(买不起Parallels Deskt ...

  8. Vi编辑器中查找替换

    1 第一个是替换当前行的yesterday为all 第二个是替换全局的 yesterday 为all :s/yesterday/all :s/yesterday/all/g

  9. 2019.9.25使用BP和Hydra爆破相关的服务

    使用BP和Hydra爆破相关的服务. Hydra:九头蛇,开源的功能强大的爆破工具,支持的服务有很多,使用hydra爆破c/s架构的服务.使用bp爆破web登录端口. dvwa:web应用程序漏洞演练 ...

  10. 格式化json扩展

    json-handle 直接在chrome应用商店搜索JSON-handle或者去github搜索可用插件即可