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 ...
随机推荐
- canvas 绘制星座图(好玩)--转载
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" ...
- 基于Node的Web聊天室
1 项目名称 Web聊天室(<这是NodeJs实战>第二章的一个案例,把整个开发过程记录下来)
- 树的直径(两个bfs)
题目链接:https://cn.vjudge.net/problem/POJ-2631 树的直径:树中的最长链 具体思路:随便找一个点bfs,然后找到最长的链,然后再以找到的点作为起点进行bfs,然后 ...
- JSON与JS的区别以及转换
JSON是什么?(JSON和JavaScript对象有什么区别?)如何把JS对象转化为JSON字符串,又如何把JSON字符串转化为JavaScript对象? JSON (JavaScript Obje ...
- kvm安装准备
到实际情况下,做虚拟化是直接做在真机上. 但实验时,可以在虚拟机上进行.(因为做实验的时候没办法连接到桥接模式的网络,所以使用了NAT方式来连接网络) 在vmware安装centos 64bit fo ...
- 在Ubuntu上使用pip安装错误 read timed out 处理方法
在终端输入 pip --default-timeout=1000 install -U pip 也就是修改超时时间.
- systemd服务内容详解
systemd是Linux下的一种init软件,由Lennart Poettering带头开发,并在LGPL 2.1及其后续版本许可证下开源发布.其开发目标是提供更优秀的框架以表示系统服务间的依赖关系 ...
- POJ 3186Treats for the Cows(区间DP)
题目链接:http://poj.org/problem?id=3186 题目大意:给出的一系列的数字,可以看成一个双向队列,每次只能从队首或者队尾出队,第n个出队就拿这个数乘以n,最后将和加起来,求最 ...
- Reverse Nodes in k-Group——简单的指针问题
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If ...
- NVIDIA DIGITS 学习笔记(NVIDIA DIGITS-2.0 + Ubuntu 14.04 + CUDA 7.0 + cuDNN 7.0 + Caffe 0.13.0)
转自:http://blog.csdn.net/enjoyyl/article/details/47397505?from=timeline&isappinstalled=0#10006-we ...