hdu 1028 Sample Ignatius and the Princess III (母函数)
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
"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!"
4
10
20
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 (母函数)的更多相关文章
- hdu 1028 Ignatius and the Princess III 母函数
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- Ignatius and the Princess III(母函数)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- 1028:Ignatius and the Princess III
本题应该有两种方法: 1.母函数法 2.递推法 母函数不了解,待充分了解之后,再进行补充! 这里为递推实现的方法: 思路: 定义:n为要拆分的整数: k为拆分的项数: f[n][k]代表 n的整数拆分 ...
- 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 整数的划分问题(打表或者记忆化搜索)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1028 Ignatius and the Princess III Time Limit: 2000/1 ...
- hdu 1028 Ignatius and the Princess III 简单dp
题目链接:hdu 1028 Ignatius and the Princess III 题意:对于给定的n,问有多少种组成方式 思路:dp[i][j],i表示要求的数,j表示组成i的最大值,最后答案是 ...
- Ignatius and the Princess III HDU - 1028 || 整数拆分,母函数
Ignatius and the Princess III HDU - 1028 整数划分问题 假的dp(复杂度不对) #include<cstdio> #include<cstri ...
- 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 ...
- HDU 1028 整数拆分问题 Ignatius and the Princess III
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
随机推荐
- HTML DIV充满整个屏幕
<!DOCTYPE html> <html> <head> <title>A Little Game!</title> <meta c ...
- 特征真的越多越好吗?从特征工程角度看“garbage in,garbage out”
1. 从朴素贝叶斯在医疗诊断中的迷思说起 这个模型最早被应用于医疗诊断,其中,类变量的不同值用于表示患者可能患的不同疾病.证据变量用于表示不同症状.化验结果等.在简单的疾病诊断上,朴素贝叶斯模型确实发 ...
- .NET Core 3.0 里新的JSON API
为什么需要新的JSON API? JSON.NET 大家都用过,老版本的ASP.NET Core也依赖于JSON.NET. 然而这个依赖就会引起一些版本问题:例如ASP.NET Core某个版本需要使 ...
- 还在重复写空指针检查代码?考虑使用 Optional 吧!
一.前言 如果要给 Java 所有异常弄个榜单,我会选择将 NullPointerException 放在榜首.这个异常潜伏在代码中,就像个遥控炸弹,不知道什么时候这个按钮会被突然按下(传入 null ...
- xshell rz commend not found
sudo apt-get install lrzsz 上传rz 下载sz
- .NET中国开发者峰会11.9 下午分会场1 内容解析
China .NET Conf 2019中国 .NET 开发者峰会即将在上海召开,这次大会是一届完全由社区组织举办的中国.NET 开发者盛会,我们筹备大会之初就定下了大会的主题是“开源.共享.创新”. ...
- redis之Scan
scan 相比keys 具备有以下特点:1.复杂度虽然也是 O(n),但是它是通过游标分步进行的,不会阻塞线程;2.提供 limit 参数,可以控制每次返回结果的最大条数,limit 只是一个 hin ...
- linux 中 NTP 对时过程记录
1.连接需要对时的服务器 $: ntpdate -u 服务器ip地址 2.写对时任务的脚本 #:crontab -e 选择 2(nano编辑): 59 23 * * * /usr/sbin/ntpda ...
- Spring MVC(2)Spring MVC 组件开发
一.控制器接收各类请求参数 代码测试环境: 接收各类参数的控制器--ParamsController package com.ssm.chapter15.controller; @Controller ...
- Redis(十三)Python客户端redis-py
一.安装redis-py的方法 使用pip install安装redis-py C:\Users\BigJun>pip3 install redis Collecting redis Downl ...