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 ...
随机推荐
- SpringBoot学习(一)—— idea 快速搭建 Spring boot 框架
简介 优点 Spring Boot 可以以jar包的形式独立运行,运行一个Spring Boot 项目只需要通过 java -jar xx.jar 来运行. Spring Boot 可以选择内嵌Tom ...
- Python装饰器的使用
对于python编程人员,装饰器的使用肯定是必不可少的. 装饰器分为系统定义装饰器和自定义装饰器:系统定义装饰器:@classmethod:类方法装饰器 @staticmethod: 静态方法装 ...
- 作业要求2018092609-2 选题 Scrum立会报告+燃尽图 01
本组第一次作业 已由组员刘信鹏同学个人博客提交 链接 : [https://www.cnblogs.com/liuxp775/p/11595227.html]
- css+js相关笔记
作者:故事我忘了c个人微信公众号:程序猿的月光宝盒 css部分: 1.内联元素垂直居中的设置: (1) 设置父级元素的行高 line-height,和高度 height 原则:line-heigh ...
- python 实现图片批量加入水印!pillow 入门实战!
写文章的时候可以设置是否添加水印.可是,有些图片可能想加水印,有些不想加水印,该怎么办呢? 配置环境 python3 + pillow pip3 install pillow 引入库 from PIL ...
- ApplicationInsights入门到精通系列(一)
在11月9号的上海.Net Conf开发者峰会上,我做了一个对Application Insights的Persentation,本来想着快速将其转化为一篇博客无赖最近忙成
- 【前端】 在前端利用数学函数知识+box-shadow解波浪图形
序 今天正在刷数学函数相关题目,刷到了下面这篇文章,哇哦-有意思. 利用cos和sin实现复杂的曲线.传送门在下面. CSS 技巧一则 -- 在 CSS 中使用三角函数绘制曲线图形及展示动画 正巧在复 ...
- LeetCode 5276. 不浪费原料的汉堡制作方案 Number of Burgers with No Waste of Ingredients
地址 https://leetcode-cn.com/problems/number-of-burgers-with-no-waste-of-ingredients/ 目描述圣诞活动预热开始啦,汉堡店 ...
- Linux -- 进程间通信之信号量
基本概念简述 多个线程同时访问一个共享数据,很可能造成恶劣的后果:为了保证数据访问资源的正确性和安全性,需要对线程进行"同步" (Linux下所有的执行实体都称为任务(task), ...
- django ListView
context_object_name = 'posts'. The template default name is ListView 'object_list' from .models impo ...