先咕着

---------------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 已咕的更多相关文章

  1. HDU-1028 Ignatius and the Princess III(生成函数)

    题意 给出$n$,问用$1$到$n$的数字问能构成$n$的方案数 思路 生成函数基础题,$x^{n}$的系数即答案. 代码 #include <bits/stdc++.h> #define ...

  2. HDU1028 Ignatius and the Princess III 【母函数模板题】

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  3. hdu1028 Ignatius and the Princess III(递归、DP)

    Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

  4. hdu1028 Ignatius and the Princess III

    这是道典型的母函数的题目,可以看看我的母函数这一标签上的另一道例题,里面对母函数做了较为详细的总结.这题仅贴上代码: #include"iostream" using namesp ...

  5. 【母函数】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; ...

  6. 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 ...

  7. HDU 1028 Ignatius and the Princess III (生成函数/母函数)

    题目链接:HDU 1028 Problem Description "Well, it seems the first problem is too easy. I will let you ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 新手应知道的ASP.NET代码编写规范

    1.局部变量的名称要有意义,尽量用对应的英文命名,比如“用户姓名”变量,不要用aa bb cc等来命名,而要使用userName. 2.不要使用单个字母的变量,如i.n.x等.而要使用index.te ...

  2. 【CODEVS】1033 蚯蚓的游戏问题

    [算法]网络流-最小费用最大流(费用流) [题解]与方格取数2类似 在S后添加辅助点S_,限流k 每条边不能重复走,限流1 #include<cstdio> #include<alg ...

  3. iOS7开发-Apple苹果iPhone开发Xcode官方文档翻译PDF下载地址(2014年2月19日更新版)

    //转载请注明出处--本文永久链接:http://www.cnblogs.com/ChenYilong/p/3496069.html     编号 iOS-Apple苹果官方文档翻译名称 博文链接地址 ...

  4. 【leetcode 简单】第五题 最长公共前缀

    编写一个函数来查找字符串数组中的最长公共前缀. 如果不存在公共前缀,返回空字符串 "". 示例 1: 输入: ["flower","flow" ...

  5. keypress 、keydown、keyup后触发回车

    1.keypress .keydown.keyup的区别 keypress表示键盘按下的全过程,只有按下任意字母数字键(后退.删除等系统功能键无效)时才触发,捕获到的keyCode区分大小写 keyd ...

  6. NASA: A Closer View of the Moon(近距离观察月球)

    Posted to Twitter by @Astro_Alex, European Space Agency astronaut Alexander Gerst, this image shows ...

  7. Appium环境搭建说明(包括报错处理)

    Appium环境搭建说明 一.环境配置 前提是windows系统已安装以下软件: 1.jdk 我装的是1.8.0 2.android-sdk 3.python,3.4-3.6 5.Node.js,v8 ...

  8. tracert和traceroute使用

    Traceroute提取发 ICMP TTL到期消息设备的IP地址并作域名解析.每次 ,Traceroute都打印出一系列数据,包括所经过的路由设备的域名及 IP地址,三个包每次来回所花时间. 转自 ...

  9. 【转载】在GitHub上管理项目

    在GitHub上管理项目 新建repository 本地目录下,在命令行里新建一个代码仓库(repository) 里面只有一个README.md 命令如下: touch README.md git ...

  10. 【转载】WebDriver(C#)之十点使用心得

    使用Selenium WebDriver驱动浏览器测试的过程中多多少少会遇到一些折腾人的问题,总结了一部分,做下分享. 一.隐藏元素处理(element not visible) 使用WebDrive ...