Ignatius and the Princess III(杭电1028)(母函数)
Ignatius and the Princess III
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 13553 Accepted Submission(s): 9590
"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#include<stdio.h>
int a[130],s[130];
int main()
{
int n,i,j,k;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<=n;i++)
{
a[i]=0;
s[i]=1;
}
for(i=2;i<=n;i++)
{
for(j=0;j<=n;j++)
{
for(k=0;k+j<=n;k+=i)
a[k+j]+=s[j];
}
for(j=0;j<=n;j++)
{
s[j]=a[j];
a[j]=0;
}
}
printf("%d\n",s[n]);
}
return 0;
}
Ignatius and the Princess III(杭电1028)(母函数)的更多相关文章
- HDU 1028 Ignatius and the Princess III:dp or 母函数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028 题意: 给你一个正整数n,将n拆分成若干个正整数之和,问你有多少种方案. 注:"4 = ...
- 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 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
题目链接:hdu 1028 Ignatius and the Princess III 题意:对于给定的n,问有多少种组成方式 思路:dp[i][j],i表示要求的数,j表示组成i的最大值,最后答案是 ...
- 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 ...
- 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 ...
- HDOJ 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
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
随机推荐
- 题解 P1774 【最接近神的人_NOI导刊2010提高(02)】
这道题很明显是求逆序对. 所谓逆序对,就是逆序的数对. 譬如在下面这个数列中: 1 2 3 4 6 5 6 5就是一个逆序对. 求逆序对的方法比较多,常见的有归并排序和树状数组(线段树当然也行). 本 ...
- POJ2891 Strange Way to Express Integers (扩展欧几里德)
本文为博主原创文章,欢迎转载,请注明出处 www.cnblogs.com/yangyaojia 题目大意 求解一组同余方程 x ≡ r1 (mod a1) x ≡ r2 (mod a2) x ≡ r ...
- HDU 4305 Contest 1
感觉是有很多细节要处理的.尤其是求逆元后的运算,应该是存在超范围的情况的. #include <iostream> #include <cstdio> #include < ...
- intellij idea 打开两个 terminal
intellij idea 打开两个 terminal alt+f12可以打开terminal,在terminal窗口左侧点击绿色的加号,就可以又打开一个terminal,用tab标签展示:
- 安卓版微信自带浏览器和IE6浏览器ajax请求abort错误处理
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/46419567 给页面元素绑定了一个click事件用来触发ajax请求.在安卓微信自 ...
- 关于Javakeywordsynchronized——单例模式的思考
精彩的设计模式盛宴刚刚落下帷幕.三天的时间.真是学习到了非常多.当中,遗留的非常多的问题.今天就谈谈synchronized这个keyword.关于对synchronizedkeyword的思考是从单 ...
- Android应用内加载pdf的方法?
[可行] 最直接的方式下载到本地, 然后调用相关应用打开 [可行,有局限] 使用 webview 加载, 需要在 原url 前面加上 http://docs.google.com/gview?url= ...
- 使用Networkx进行图的相关计算——黑产集团挖掘,我靠,可以做dns ddos慢速攻击检测啊
# -*- coding: utf-8 -*- import networkx as nx import matplotlib.pyplot as plt iplist={} goodiplist={ ...
- SparkSession - Spark SQL 的 入口
SparkSession - Spark SQL 的 入口 翻译自:https://jaceklaskowski.gitbooks.io/mastering-apache-spark/content/ ...
- c#邮件发送服务
邮件发送服务 项目中会遇到定时给某人发送邮件的功能要求,这里是京东的一段代码,当然也是我同事找的,我记录学习一下,以免忘记. 这是解决方案 这里主要是工具:日志工具,链接数据库工具,发送邮件工具 这里 ...