大意是给你1个整数n,问你能拆成多少种正整数组合。比如4有5种:

4 = 4;
  4 = 3 + 1;
  4 = 2 + 2;
  4 = 2 + 1 + 1;
  4 = 1 + 1 + 1 + 1;

然后就是母函数模板题……小于n的正整数每种都有无限多个可以取用。

(1+x+x^2+...)(1+x^2+x^4+...)...(1+x^n+...)

答案就是x^n的系数。

#include<cstdio>
#include<cstring>
using namespace std;
int n,a[123],b[123];
int main()
{
while(scanf("%d",&n)!=EOF)
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
a[0]=1;
for(int i=1;i<=n;++i)
{
for(int j=0;j<=n;++j)
for(int k=0;k*i+j<=n;++k)
b[k*i+j]+=a[j];
memcpy(a,b,sizeof(a));
memset(b,0,sizeof(b));
}
printf("%d\n",a[n]);
}
return 0;
}

【母函数】hdu1028 Ignatius and the Princess III的更多相关文章

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

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

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

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

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

  4. hdu1028 Ignatius and the Princess III

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

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

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

  6. hdu1028 Ignatius and the Princess III(生成函数整理占坑)upd 已咕

    先咕着 ---------------2018 5 22---------------------- 题解 生成函数处理整数拆分 code #include<cstdio> #includ ...

  7. Ignatius and the Princess III(母函数)

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

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

  9. Ignatius and the Princess III HDU - 1028 || 整数拆分,母函数

    Ignatius and the Princess III HDU - 1028 整数划分问题 假的dp(复杂度不对) #include<cstdio> #include<cstri ...

随机推荐

  1. spring中@PropertySource注解的使用

    概述: The @PropertySource annotation provides a convenient and declarative mechanism for adding aPrope ...

  2. oracleLinux7上安装oracle11g r2(脚本简单配置环境)

    一 环境脚本简单配置 #!/bin/bashmv /etc/yum.repos.d/* /tmpmv iso.repo /etc/yum.repos.d/tar zxvf a.tar.gzmv 7Se ...

  3. php函数-shuffle

    Shuffle()函数说明: -随机乱序现有数组并不保留键值: -shuffle()函数把数组中的元素按随机顺序重新排列,该函数为数组中的元素分配新的键名,已有键名将被删除. 语法说明: shuffl ...

  4. React.js基础知识

    一. react.js的基本使用方法 (1)快速使用,hello world <div id="app"></div> <script src=&qu ...

  5. 关于CRC循环冗余校验的总结(C#)

    1. 实验要求 (1)通过CRC(循环冗余校对)序列的计算,掌握C#语言中类的静态方法与动态方法的区别. (2)Shell与Windows Form 的通信作为扩展提高内容. 2. 实验内容  主要工 ...

  6. ()()()()x()=()()()()填1-9数字

    /** Function: ()()()()x()=()()()() Developer: Date: */ #include "iostream" #include " ...

  7. 【BZOJ1976】能量魔方 [最小割]

    能量魔方 Time Limit: 10 Sec  Memory Limit: 64 MB[Submit][Status][Discuss] Description 小C 有一个能量魔方,这个魔方可神奇 ...

  8. JAVA开发环境及其开发

    成功安装之后,进行测试是否真的成功安装,点击[开始]----[运行]----输入 CMD,在命令提示符里面输入"Java -version"并按回车键,出现下图,即为安装成功. 选 ...

  9. 这个命令可以看到你的cpu到底集合

      cat /proc/cpuinfo  |grep processor|awk '{print $3}'|wc -l    改变虚拟机分辨率  xrandr -s 1024x768 -r 60  或 ...

  10. JVM指令的使用深入详解

    原文地址:https://www.jb51.net/article/155293.htm 一.未归类系列A 此系列暂未归类. 指令码    助记符                            ...