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 ...
随机推荐
- gulp - sass 插件一直安装不好?
1.没有sass,只存在与scss 任务 gulp.task('scss', function() { return gulp.src(app.srcPath + '/sass/*.scss') .p ...
- Missing 'name' key attribute on element activity at AndroidMan
<uses-permission android:content="android.permission.CHANGE_WIFI_STATE" /> 这是android ...
- 从头学起-CLR的执行模型
1.将源代码编译成托管代码 公共运行时(Common Language Runtime) a.面向运行时的所有语言都可以通过异常报告错误 b.面向运行时的所有语言都可以创建线程 c.核心功能:管理内存 ...
- C# Backgroundworker(后台线程)的使用
namespace BackgroundWorkderPauseSample { public partial class MainForm : Form { BackgroundWorker wor ...
- 读懂这些spring boot的核心注解,快速配置完成项目搭建
在spring boot中,摒弃了spring以往项目中大量繁琐的配置,遵循约定大于配置的原则,通过自身默认配置,极大的降低了项目搭建的复杂度.同样在spring boot中,大量注解的使用,使得代码 ...
- JAVA的WebService规范JAX-WS
JAX-WS的服务端.客户端双方传输数据使用的SOAP消息格式封装数据. 一.下载apache-cxf-3.1.4.zip. 二.编写服务端 1.编写一个Web Service用来传输参数的类 pac ...
- asp.net连接Access数据库实现登陆功能
这里话就不多说了,直接演示代码. 连接access数据库首先需要配置web.config <appSettings> <add key="AccessConnString& ...
- gRPC错误码 http状态码 provide your APIs in both gRPC and RESTful style at the same time
How gRPC error codes map to HTTP status codes in the response https://github.com/grpc-ecosystem/grpc ...
- 在Android Studio中修改应用包名
紧凑模式下(包名中的每个字段紧贴在一起,例如),右键单击包名,Refactor -> Rename,只能修改包名最外层的字段 分离模式下(点击设置,将Hide Empty Middle Pack ...
- Quartz -第一篇-入门
学习地址:https://www.imooc.com/learn/846 官网:www.quartz-scheduler.org 特点:分布式+集群 设计模式: 工厂模式 builder模式 组件模式 ...