hdu 1028 Ignatius and the Princess III【生成函数】
老是想着化简,实际上O(n^3)就行了……
写成生成函数是\( \prod_{i=1}{n}(1+xi+2{2i}+...+x{ \left \lfloor \frac{n}{i} \right \rfloor }) \),暴力乘即可
#include<iostream>
#include<cstdio>
using namespace std;
const int N=125;
int n,a[N],b[N];
int main()
{
while(~scanf("%d",&n))
{
for(int i=0;i<=n;i++)
a[i]=1,b[i]=0;
for(int i=2;i<=n;i++)
{
for(int j=0;j<=n;j++)
for(int k=0;k<=n;k+=i)
b[j+k]+=a[j];
for(int j=0;j<=n;j++)
a[j]=b[j],b[j]=0;
}
printf("%d\n",a[n]);
}
return 0;
}
hdu 1028 Ignatius and the Princess III【生成函数】的更多相关文章
- 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 简单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 ...
随机推荐
- Indri和Terrier搜索引擎的使用
介绍 Indri和Terrier都是开源的搜索引擎,当中Indri作为Lemur项目的一个重要部分,具有强大的查询接口,易建索引,可扩展,高效率等长处.能够在SourceForge Lemur Pro ...
- JQUERY多选框,单选框,检查选中的值
var str=""; $(":checkbox:checked").each(function(){ if($(this).attr("checke ...
- maven插件介绍之maven-jar-plugin
maven-jar-plugin 插件的maven依赖为: <dependency> <groupId>org.apache.maven.plugins</groupId ...
- 【Web前端】清除浮动&css中文字体
清理浮动有非常多种方式,像使用 br 标签自带的 clear 属,使用元素的 overflow.使用空标签来设置 clear:both 等等.但考虑到兼容问题和语义化的问题,一般我们都会使用例如以下代 ...
- Appium基于安卓的各种FindElement的控件定位
转自:http://www.2cto.com/kf/201410/340345.html 1. findElementByName 1.1 示例 ? 1 2 el = driver.findEleme ...
- [转]XCode中修改缺省公司名称/开发人员名称
本文转载至 http://www.cnblogs.com/zhulin/archive/2011/11/24/2261537.html XCode新建文件后,头部会有开发人员名称,公司名称等信息 ...
- 深度学习入门-4.1 AND.py 源码分析
源代码 ------------------------------------------------------------------------------------------------ ...
- HttpServletRequestWrapper模拟实现分布式Session
HttpSession的内容都放在一个单独的Map中,模拟远程分布式Session. 1.使用HttpServletRequestWrapper创建自定义Request2.使用动态代理包装自定义Req ...
- (linux)SD卡初始化-mmc_sd_init_card函数(续)
转自:http://www.cnblogs.com/fengeryi/p/3472728.html mmc_sd_init_card剩下的关于UHS-I的分支结构. uhs-I的初始化流程图如 ...
- 计算一个大数n的阶乘的位数宽度(十进制)(log i累加法 )
输入: 每行输入1个正整数n, (0<n<1000 000) 输出: 对于每个n,输出n!的(十进制)位数. 分析: 这道题采用蛮力法.根据定义,直接求解! 所谓n!的十进制位数,就是 l ...