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 (Java/Others)
Total Submission(s): 26219 Accepted Submission(s): 18101
"The second problem is, given an positive integer N, we define an equation like this:
N=a[1]+a[2]+a[3]+...+a[m];
a[i]>0,1<=m<=N;
My question is how many different equations you can find for a given N.
For example, assume N is 4, we can find:
4 = 4;
4 = 3 + 1;
4 = 2 + 2;
4 = 2 + 1 + 1;
4 = 1 + 1 + 1 + 1;
so the result is 5 when N is 4. Note that "4 = 3 + 1" and "4 = 1 + 3" is the same in this problem. Now, you do it!"
10
20
42
627
#include <cstdio>
#include <cstring> using namespace std; const int maxn=; //动规打表
int dp[maxn+][maxn+]; int sum[maxn+]; int main()
{
memset(dp,,sizeof(dp));
memset(sum,,sizeof(sum));
for(int i=;i<=maxn;++i)
{
dp[i][]=dp[i][i]=;
for(int j=;j<=i-;++j)
{
for(int k=;k<=j;++k)
{
dp[i][j]+=dp[i-j][j-k];
}
}
for(int j=;j<=i;++j)
{
sum[i]+=dp[i][j];
}
} int n;
while(scanf("%d",&n)!=EOF)
{
printf("%d\n",sum[n]);
} return ;
}
hdu 1028 Ignatius and the Princess III (n的划分)的更多相关文章
- HDU 1028 Ignatius and the Princess III dp整数划分
http://acm.hdu.edu.cn/showproblem.php?pid=1028 dp[i][j]表示数值为i,然后最小拆分的那个数是j的时候的总和. 1 = 1 2 = 1 + 1 . ...
- hdu 1028 Ignatius and the Princess III 简单dp
题目链接:hdu 1028 Ignatius and the Princess III 题意:对于给定的n,问有多少种组成方式 思路:dp[i][j],i表示要求的数,j表示组成i的最大值,最后答案是 ...
- 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 ...
- 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 ...
- 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 ...
- hdu 1028 Ignatius and the Princess III 母函数
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- HDU 1028 Ignatius and the Princess III (递归,dp)
以下引用部分全都来自:http://blog.csdn.net/ice_crazy/article/details/7478802 Ice—Crazy的专栏 分析: HDU 1028 摘: 本题的意 ...
- HDU 1028 Ignatius and the Princess III (生成函数/母函数)
题目链接:HDU 1028 Problem Description "Well, it seems the first problem is too easy. I will let you ...
- HDU 1028 Ignatius and the Princess III (动态规划)
题目链接:HDU 1028 Problem Description "Well, it seems the first problem is too easy. I will let you ...
随机推荐
- Redis为什么是单线程、及高并发快的3大原因详解
Redis的高并发和快速原因 1.redis是基于内存的,内存的读写速度非常快: 2.redis是单线程的,省去了很多上下文切换线程的时间: 3.redis使用多路复用技术,可以处理并发的连接.非阻塞 ...
- cognos服务器性能测试诊断分析优化过程记录
前段时间客户方一个系统上线后出现性能问题,就是查询报表的时候出现宕机现象,应项目组要求过去帮忙测试优化问题. 该项目的架构相对比较复杂,登录后要先进行认证服务器认证用户然后登录到应用系统A,在跳转到 ...
- 【2018寒假集训 Day1】【位运算】桐桐的运输方案
桐桐的运输方案(transp) [问题描述] 桐桐有 N 件货物需要运送到目的地,它们的重量和价值分别记为: 重量:W1,W2,…,Wn: 价值:V1,V2,…,Vn: 已知某辆货车的最大载货量为 X ...
- scrapy下载中间件结合selenium抓取全国空气质量检测数据
1.所需知识补充 1.下载中间件常用函数 process_request(self, request, spider): 当每个request通过下载中间件是,该方法被调用 process_reque ...
- 如何平滑优雅地在Rancher 2.x中升级cert-manager?
作者: Nassos Michas丨European Dynamics SA, CTO 如果你正在使用由Rancher提供的Helm Chart在Rancher管理的Kubernetes集群中安装ce ...
- 【Java基础】字面量相加的类型转换
Java字面量的相加类型转换 1.Java 编译期间(javac),凡是字面量和常量的运算,都会先运算出结果 2.运行期当字符串池中有 String"字面量"时,Java 会直接用 ...
- css之文本两端对齐的两种解决方法
说起文本对齐,大家都知道text-align,最常用的有left.right.center,今天我们说一下justify,也就是文本两端 对齐.说起来简单,但是有些小坑大家还是要注意的. 现在我们有这 ...
- jQuery九宫格抽奖
<div id="box"> <div class="content content-1">1</div> <div ...
- 2019-2020-11 20199304 《Linux内核原理与分析》 第十二周作业
ShellShock攻击实验 一.实验简介 2014年9月24日,Bash中发现了一个严重漏洞shellshock,该漏洞可用于许多系统,并且既可以远程也可以在本地触发 二.预备知识 1.shells ...
- java多线程与线程池
1. 场景描述 以前多线程也常用,这次因需再页面上用到多线程,如下图,总结下,有需要的朋友可以参考下. 2. 解决方案 2.1 线程池概念 线程池官方定义不说了,通俗说下:池子的概念,事先(预定义)创 ...