hdu 1028 Ignatius and the Princess III
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028
题目大意:3=1+1+1=1+2=3 ;4=4=1+1+1+1=1+2+1=1+3;所以3有3种加法,4有4种加法,给出一个n,(1<=n<=120) ,计算n有几种加法。
解法:母函数的最简单的一道入门题之一。
说明:今早上突发奇想着想学学母函数,就搜了搜HDU ACM PPT 的母函数一版,把这道题分享给大家。
感想:这道题之前看过,推过公式什么的,没推出来。今天才知道是母函数的算法。算法果然奇妙啊,我得加紧学习算法了。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#define inf 0x7fffffff
using namespace std;
int main()
{
int an[],bn[];
int n;
while (cin>>n)
{
for (int i= ;i<=n ;i++) {an[i]= ;bn[i]= ; }
//模拟多项式乘法
for (int i= ;i<=n ;i++) // 从第二个多项式开始枚举
{
for (int j= ;j<=n ;j++)//枚举第一个多项式的系数
{
for (int k= ;k+j<=n ;k+=i) //枚举第i个多项式各项系数
{
bn[j+k] += an[j];
}
}
for (int j= ;j<=n ;j++)
{
an[j]=bn[j];
bn[j]=;
}
}
printf("%d\n",an[n]);
}
return ;
}
hdu 1028 Ignatius and the Princess III的更多相关文章
- 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 (n的划分)
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 ...
随机推荐
- SQL服务器更改名称后
SQL服务器更改名称后 编写人:CC阿爸 2014-6-15 在日常SQL 2005数据库的操作中,有时安装完成数据库后,再更名,造成部分SQL服务不能正常使用(在SQL2000 时,想都别想更名了) ...
- ASP.net UrlRewrite的防盗链功能
ASP.net中如何实现基于UrlRewrite的防盗链. ASP.net中最快实现UrlRewrite的方法这篇文章中说了如何做UrlRewrite,那只是一个最简单的应用 其实利用UrlRewri ...
- Android判断横屏竖屏代码
// 判断Android当前的屏幕是横屏还是竖屏.横竖屏判断 if (this.getResources().getConfiguration().orientation == Configurati ...
- DevExpress LookUpEdit和ComboBoxEdit部分用法
LookUpEdit 1.绑定列 (注意点:LookUpEdit1的FieldName要和绑定的列明一致) 方式一: LookUpEdit1.Properties.DisplayMember = &q ...
- JDBC基础一
JDBC:java database connectivity SUN公司提供的一套操作数据库的标准规范. JDBC与数据库驱动的关系:接口与实现的关系. JDBC规范(掌握四个核心对象): Driv ...
- 蒙牛乳业六厂—第一家MES工厂
在上海西门子工业自动化(SIAS)与蒙牛液态奶事业部以及蒙牛集团信息中心的共同努力下,经过项目组成员1年半时间的具体实施,中国乳品行业第一个真正意义上的生产执行系统MES,于2008年6月在蒙牛乳业集 ...
- Mongodb的索引--学习笔记(未完)
全文索引 建立方法: --在articles集合的key字段上创建全文索引 db.articles.ensureIndex({key:"text"}) --在articles集合的 ...
- 如何查找STM32开发资料
Ⅰ.概述 该文写给那些处于初学ST芯片开发.英文不好而又想偷懒的人. 该文主要的目的是提醒大家:学习一门技术是需要舍得花功夫,捷径是你在起点与终点之间不断的探索,最终总结出来的一条适合自己的路. 下面 ...
- Linq的一些记录
1. IQueryable接口与IEnumberable接口的区别: IEnumerable<T> 泛型类在调用自己的SKip 和 Take 等扩展方法之前数据就已经加载在本地内存里了, ...
- VC下的人人对弈五子棋(dos)
#include"stdio.h"#include"stdlib.h"#include"string.h"#include "io ...