hdoj--1028--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): 16242 Accepted Submission(s): 11445
"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>
#include<string.h>
#define max 100+30
int main()
{
int c1[max],c2[max];
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=0;i<=n;i++)
{
c1[i]=1;
c2[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)//在第i个多项式中的每一项与前边的相乘
c2[k+j]+=c1[j];
for(int j=0;j<=n;j++)
{
c1[j]=c2[j];//更新现在第一个多项式中的每一项的系数
c2[j]=0;
}
}
printf("%d\n",c1[n]);
}
return 0;
}
hdoj--1028--Ignatius and the Princess III(母函数)的更多相关文章
- 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 ...
- hdoj 1028 Ignatius and the Princess III(区间dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028 思路分析:该问题要求求出某个整数能够被划分为多少个整数之和(如 4 = 2 + 2, 4 = 2 ...
- HDOJ 1028 Ignatius and the Princess III(递推)
Problem Description "Well, it seems the first problem is too easy. I will let you know how fool ...
- 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 ...
- 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 Sample 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 ...
- 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 ...
随机推荐
- Spark Scala语言学习系列之完成HelloWorld程序(三种方式)
三种方式完成HelloWorld程序 分别采用在REPL,命令行(scala脚本)和Eclipse下运行hello world. 一.Scala REPL. windows下安装好scala后,直接C ...
- WCF WEB HTTP请求 WCF REST FUL
首先上点概念WCF 很好的支持了 REST 的开发, 而 RESTful 的服务通常是架构层面上的考虑. 因为它天生就具有很好的跨平台跨语言的集成能力,几乎所有的语言和网络平台都支持 HTTP 请求, ...
- Android Studio插件:Android Drawable Importer
Android Drawable Importer 为了在不同分辨率的设备上更好的展示图片的效果,我们往往需要在 res/drawable 中添加不同分辨率的图片.有时我们可能手里只有一份分辨率的图片 ...
- 错误:the apk for your currently selected variant(app-release-unsigned.apk)is not signed.Please specity a signing configuration for this variant(release)
1:导入android studio project 时总会出现运行处一个红色叉号,这里可以点击选择叉号上面显示的Edit Configurations 查看右下角的错误警告信息.: 2:记录错误: ...
- span可编辑 属性 html 可编辑td
<span contenteditable="true">11111111111111111</span> <!DOCTYPE html PUBLIC ...
- c++ socket C/S通信实例
具体的实例连接: 客户端项目连接:http://pan.baidu.com/s/1c2MndTI 服务端项目连接:http://pan.baidu.com/s/1i4DFkFV 用vs2013打开,服 ...
- JDBC连接MySQL数据库(一)——数据库的基本连接
JDBC的概念在使用之前我们先了解一下JDBC的概念, JDBC的全称是数据库连接(Java Database Connectivity),它是一套用于执行SQL语句时的API,应用程序可以通过这套A ...
- vncserve安装与使用
vncserver安装与配置 1.1.Centos安装 yum install tigervnc-server yum groupinstall "X Window System" ...
- PHP回顾之协程
转载请注明文章出处: https://tlanyan.me/php-review... PHP回顾系列目录 PHP基础 web请求 cookie web响应 session 数据库操作 加解密 Com ...
- 基于ALSA的WAV播放和录音程序
http://blog.csdn.net/azloong/article/details/6140824 这段时间在探索ALSA架构,从ALSA Core到ALSA Lib,再到Android Aud ...