hdu acm 1028 数字拆分Ignatius and the Princess III
Ignatius and the Princess III
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 11810 Accepted Submission(s): 8362
"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!"
最简单的母函数模板题,用于学习和回顾母函数非常方便,代码也可直接做模板使用
/*
hdu acm 1028 数字拆分,母函数模板题
by zhh
*/
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cstring> using namespace std;
#define maxx 120
int ans[maxx+],temp[maxx+];
void init()//母函数打表
{
for(int i=;i<=maxx;i++)//初始化第一个式子系数
{
ans[i]=;
temp[i]=;//用于临时保存每次相乘的结果
}
for(int i=;i<=maxx;i++)//循环每一个式子
{
for(int j=;j<=maxx;j++)//循环第一个式子各项
for(int k=;k+j<=maxx;k+=i)//下个式子的各项
temp[k+j]+=ans[j];//结果保存到temp数组中
for(int j=;j<=maxx;j++)//临时保存的值存入ans数组
{
ans[j]=temp[j];
temp[j]=;
}
}
}
int main()
{
init();
int n;
while(scanf("%d",&n)!=EOF)
{
cout<<ans[n]<<endl;
}
return ;
}
hdu acm 1028 数字拆分Ignatius and the Princess III的更多相关文章
- ACM学习历程—HDU1028 Ignatius and the Princess III(递推 || 母函数)
Description "Well, it seems the first problem is too easy. I will let you know how foolish you ...
- Ignatius and the Princess III HDU - 1028 || 整数拆分,母函数
Ignatius and the Princess III HDU - 1028 整数划分问题 假的dp(复杂度不对) #include<cstdio> #include<cstri ...
- 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 整数的划分问题(打表或者记忆化搜索)
传送门: 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
题目链接:hdu 1028 Ignatius and the Princess III 题意:对于给定的n,问有多少种组成方式 思路:dp[i][j],i表示要求的数,j表示组成i的最大值,最后答案是 ...
- 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)
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 Sample Ignatius and the Princess III (母函数)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
随机推荐
- PHP 7 Xdebug 深深的坑
zend_extension 7.0 下的 php.ini 配置 [XDebug];; Only Zend OR (!) XDebugzend_extension=f:\xampp\php\ext\p ...
- 初学c# -- 学习笔记(七) RichTextBox支持GIF
园子里许明吉博客写的一篇,刚好用到这个,写的非常好.转过来了 不过在应用中也有一些问题,win10下不能中文输入,凑合着进行了修改, 下面是原来的代码: private void button2_Cl ...
- 笔记002:javascript简介
1. HTML服务于内容 CSS服务于表现 Javascript服务于行为(一切东西的粘合剂) 2.javascript能运行多种宿主环境中(Web浏览器最普遍) 3.历史 1995 Netscape ...
- 【css3】浏览器内核及其兼容性
浏览器内核分类如下: 1.Webkit内核: 使用此引擎内核的浏览器有:Safari(包括移动版和桌面版).Chrome.其私有属性的前缀是-webkit-. 2.Gecko内核: 使用此引擎内核的浏 ...
- 驱动开发学习笔记. 0.02 基于EASYARM-IMX283 烧写uboot和linux系统
驱动开发读书笔记. 0.02 基于EASYARM-IMX283 怎么烧写自己裁剪的linux内核?(非所有arm9通用) 手上有一块tq2440,但是不知道什么原因,没有办法烧boot进norflas ...
- 将搜狗词库.scel格式转化为.txt格式
由于项目中要用到词库,而下载的搜狗词库是.scel格式,所以就用python脚本将搜狗词库.scel格式文件转化为.txt格式文件. #!/bin/python # -*- coding: utf-8 ...
- MAC 安装 Protobuf
1.确认MAC装有g++.make.vim工具 2.安装make工具使用 brew install make 3.安装protobuf brew install protobuf 4.安装 ...
- [转] Oracle数据库备份与恢复 - 增量备份
转:http://blog.csdn.net/pan_tian/article/details/46780929 RMAN一个强大的功能是支持增量备份,增量备份中心思想就是减少备份的数据量,我们不 ...
- maven学习(5)-maven中常见错误
maven报错非法字符:\65279 错误 开发中一个项目很早就报这个错,maven报错非法字符:\ 错误, 开发过程中偶尔会遇到,今天终于下决心要解决这个问题 编译java 文件的时候,有些java ...
- Java-计划存储
Hive:Hive文档 Hdfs官方 Spark官方 About云中文论坛 书单:2015豆瓣书单 豆瓣千人8.0+书单 编程入口:Eclipse servlet java8 快捷键整理 MyBat ...