Ignatius and the Princess III

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 25929    Accepted Submission(s): 17918

Problem Description
"Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says.

"The second problem is, given an positive integer N, we define an equation like this:
  N=a[1]+a[2]+a[3]+...+a[m];
  a[i]>0,1<=m<=N;
My question is how many different equations you can find for a given N.
For example, assume N is 4, we can find:
  4 = 4;
  4 = 3 + 1;
  4 = 2 + 2;
  4 = 2 + 1 + 1;
  4 = 1 + 1 + 1 + 1;
so the result is 5 when N is 4. Note that "4 = 3 + 1" and "4 = 1 + 3" is the same in this problem. Now, you do it!"

 
Input
The input contains several test cases. Each test case contains a positive integer N(1<=N<=120) which is mentioned above. The input is terminated by the end of file.
 
Output
For each test case, you have to output a line contains an integer P which indicate the different equations you have found.
Sample Input
4
10
20
 
Sample Output
5
42
627

C/C++:

 #include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <climits>
#include <iostream>
#include <algorithm>
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
const int MAX = 2e2 + ; int n, ans[MAX], temp[MAX]; void calc()
{
for (int i = ; i <= ; ++ i)
ans[i] = , temp[i] = ;
for (int i = ; i <= ; ++ i)
{
for (int j = ; j <= ; ++ j)
for (int k = ; j + k <= ; k += i)
temp[j + k] += ans[j];
for (int j = ; j <= ; ++ j)
ans[j] = temp[j], temp[j] = ;
}
} int main()
{
calc();
while (~scanf("%d", &n))
printf("%d\n", ans[n]);
return ;
}

hdu 1028 Sample Ignatius and the Princess III (母函数)的更多相关文章

  1. hdu 1028 Ignatius and the Princess III 母函数

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

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

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

  3. 1028:Ignatius and the Princess III

    本题应该有两种方法: 1.母函数法 2.递推法 母函数不了解,待充分了解之后,再进行补充! 这里为递推实现的方法: 思路: 定义:n为要拆分的整数: k为拆分的项数: f[n][k]代表 n的整数拆分 ...

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

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

  6. hdu 1028 Ignatius and the Princess III 简单dp

    题目链接:hdu 1028 Ignatius and the Princess III 题意:对于给定的n,问有多少种组成方式 思路:dp[i][j],i表示要求的数,j表示组成i的最大值,最后答案是 ...

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

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

  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. HDU 1028 整数拆分问题 Ignatius and the Princess III

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

随机推荐

  1. Android Studio 模拟器Intel 加速

    Starting emulator for AVD 'Phone1'emulator: ERROR: x86 emulation currently requires hardware acceler ...

  2. spark运行java-jar:Exception in thread "main" java.io.IOException: No FileSystem for scheme: hdfs

    今天碰到的一个 spark问题,困扰好久才解决 首先我的spark集群部署使用的部署包是官方提供的 spark-1.0.2-bin-hadoop2.tgz 部署在hadoop集群上. 在运行java ...

  3. JVM 启动调优总结

    启动命令 格式: java -jar 命令行参数 jar包路径 .示例如下 java -Dfile.encoding=utf-8 -jar -XX:MetaspaceSize=128m -XX:Max ...

  4. markdown(typora)基本语法

    目录 * 标题 * 加粗 * 斜体 * 高亮 * 上标 * 下标 * 代码引用(>式和```式) * 代码引入(`式) * 插入链接(链接显示) * 插入链接(连接描述显示) * 插入图片(链接 ...

  5. 数据结构(二十七)Huffman树和Huffman编码

    Huffman树是一种在编码技术方面得到广泛应用的二叉树,它也是一种最优二叉树. 一.霍夫曼树的基本概念 1.结点的路径和结点的路径长度:结点间的路径是指从一个结点到另一个结点所经历的结点和分支序列. ...

  6. 深入理解大数据架构之——Lambda架构

    目录 传统系统的问题 Lambda架构简介 Lambda架构关键特性 数据系统的本质 Lambda的三层架构 Lambda架构组件选型 总结 原文链接:https://jiang-hao.com/ar ...

  7. (Java) AES-128 数据加密

    package com.vcgeek.hephaestus.utils; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeyS ...

  8. Flutter学习笔记--Dart基础

    前言 Flutter使用Dart语言开发, Dart是面向对象编程语言, 由Google2011年推出, 目前最新版本是2.4.0. 工欲善其事,必先利其器. 为了更好的开发Flutter应用, 我们 ...

  9. 一文搭建自己博客/文档系统:搭建,自动编译和部署,域名,HTTPS,备案等

    本文纯原创,搭建后的博客/文档网站可以参考: Java 全栈知识体系.如需转载请说明原处. 第一部分 - 博客/文档系统的搭建 搭建博客有很多选择,平台性的比如: 知名的CSDN, 博客园, 知乎,简 ...

  10. 在虚拟机上的关于Apache(阿帕奇)(1)开启Apache服务以及介绍基础服务

    我们来开始讲述Apache(阿帕奇)服务 小知识: Apache   使得一台服务器上放很多网站,网站同时访问  可以使网站更安全(木马如果是root权限  如果webshell  apache 可用 ...