hdu1028 Ignatius and the Princess III(生成函数整理占坑)upd 已咕
先咕着
---------------2018 5 22----------------------
题解
生成函数处理整数拆分
code
#include<cstdio>
#include<cstring>
#include<algorithm>
inline int raed() {
int x = 0,f = 1;
char c = getchar();
while(c < '0' || c < '9') c = getchar();
while(c <= '9' && c >= '0')x = x * 10 + c - '0',c = getchar();
return x * f;
}
const int maxn = 564;
int a[maxn],b[maxn];
int main() {
int n;
while(scanf("%d",&n) == 1) {
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 + j <= 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;
}
hdu1028 Ignatius and the Princess III(生成函数整理占坑)upd 已咕的更多相关文章
- HDU-1028 Ignatius and the Princess III(生成函数)
题意 给出$n$,问用$1$到$n$的数字问能构成$n$的方案数 思路 生成函数基础题,$x^{n}$的系数即答案. 代码 #include <bits/stdc++.h> #define ...
- HDU1028 Ignatius and the Princess III 【母函数模板题】
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- hdu1028 Ignatius and the Princess III(递归、DP)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- hdu1028 Ignatius and the Princess III
这是道典型的母函数的题目,可以看看我的母函数这一标签上的另一道例题,里面对母函数做了较为详细的总结.这题仅贴上代码: #include"iostream" using namesp ...
- 【母函数】hdu1028 Ignatius and the Princess III
大意是给你1个整数n,问你能拆成多少种正整数组合.比如4有5种: 4 = 4; 4 = 3 + 1; 4 = 2 + 2; 4 = 2 + 1 + 1; 4 = 1 + 1 + 1 + 1; ...
- 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 ...
- 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 acm 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 ...
随机推荐
- 【BZOJ】4873: [Shoi2017]寿司餐厅
[题目]#2146. 「SHOI2017」寿司餐厅 [题意]给定n种寿司的代号,取区间[i,j]的寿司收益是d[i,j]和所有子区间的d,吃了c(c>0)种代号x的寿司的代价是mx^2+cx,给 ...
- 【CodeForces】708 C. Centroids 树的重心
[题目]C. Centroids [题意]给定一棵树,求每个点能否通过 [ 移动一条边使之仍为树 ] 这一操作成为树的重心.n<=4*10^5. [算法]树的重心 [题解]若树存在双重心,则对于 ...
- 【CodeForces】713 C. Sonya and Problem Wihtout a Legend
[题目]C. Sonya and Problem Wihtout a Legend [题意]给定n个数字,每次操作可以对一个数字±1,求最少操作次数使数列递增.n<=10^5. [算法]动态规划 ...
- 6.MySQL简介
MySQL简介 ·点击查看MySQL官方网站 ·MySQL是一个关系型数据库管理系统,由瑞典MySQLAB公司开发,后来被Sun公司收购,Sun公司后来又被Oracle公司收购,目前属于facle旗下 ...
- python3学习笔记.2.基础
1.编码 默认编码是 utf-8 # -*- coding: utf-8 -*- 2.注释 单行注释 # 多行注释,用三个单引号或双引号 3.关键字 可在交互窗口查询. >>> i ...
- python基础之常用的高阶函数
前言 高阶函数指的是能接收函数作为参数的函数或类:python中有一些内置的高阶函数,在某些场合使用可以提高代码的效率. map() map函数可以把一个迭代对象转换成另一个可迭代对象,不过在pyth ...
- React 16 源码瞎几把解读 【三 点 一】 把react组件对象弄到dom中去(矛头指向fiber,fiber不解读这个过程也不知道)
一.ReactDOM.render 都干啥了 我们在写react的时候,最后一步肯定是 ReactDOM.render( <div> <Home name="home&qu ...
- plsql例子
create or replace procedure find_difference(db_link in varchar2) is /* 比对两套环境建表脚本差异,以224环境为主 当前环境,db ...
- 连接数据库:ERROR:The server time zone value '?й???????' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration prop
本打算在maven项目中配置mybatis试试看,想到mybatis如果不是在容器中运行,那么他的事务控制实际上可以使用的是jdbc的提交和回滚,这就要在pom.xml文件中配置mysql-conne ...
- jmeter----计数器
在测试过程中,往往需要一些有一定规则的数字,这个时候,可以使用配置元件中的计数器去实现. 一.界面显示 二.配置说明 1.名称:标识 2.注释:备注 3.启动:是指计数器开始的值 4.递增:每次增加的 ...