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): 9532 Accepted Submission(s): 6722
"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!"
10
20
42
627
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; const int maxn=; int c1[maxn],c2[maxn]; int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=;i<=n;i++)
{
c1[i]=; c2[i]=;
} for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
for(int k=;j+k<=n;k+=i)
c2[k+j]+=c1[j];
} for(int j=;j<=n;j++)
{
c1[j]=c2[j]; c2[j]=;
}
}
printf("%d\n",c1[n]);
} return ;
}
HDOJ 1028 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 ...
- 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 ...
随机推荐
- js验证表单大全
js验证表单大全 1. 长度限制 <script> function test() { if(document.a.b.value.length>50) { alert(" ...
- DB2行转列(多维度)
多维度下进行行列转换,下面的行列转换时根据客户,所属银行机构进行的行列转换. -----------------建表 CREATE TABLE CUST_BANK_INFO ( CUST_ID ), ...
- GestureDetector.OnGestureListener
为了加强鼠标响应事件,Android提供了GestureDetector手势识别类.通过GestureDetector.OnGestureListener来获取当前被触发的操作手势(Single Ta ...
- ajax & jsonp & img
ajax 是一种请求服务器的方式,核心是XMLHttpRequest对象: 优点是无需刷新页面, 缺点是不能跨域请求. /* * Ajax direacted by Zakas * * Ajax.ge ...
- Java之有病的policy配置
使用-Djava.security.policy=xxx.policy启动安全策略, 你会想到codesource的配置如此蛋疼么? grant CodeBase "file:////D:/ ...
- Linux如何开机自动运行自己的脚本
博客分类: LINUX 脚本LinuxCentOSWindowsBash 记录这个事情是上次完成之后,今天要新加一个文件夹,一时之间忘记以前怎么做了,因为有几种方法,起码我知道三种方法,这里 ...
- Entity Framework SqlFunctions 教你如何在EF调用sqlserver方法的函数存根
今天算是研究了一天的SqlFunctions,请教了几个群的牛人,居然发现大伙对这个都比较陌生, 有的甚至直指EF中是不能调用sqlserver里的方法的. 因为之前搞过linq to sql 里面的 ...
- Entity Framework学习笔记(二)----CRUD(1)
请注明转载地址:http://www.cnblogs.com/arhat 这篇文章老魏和大家分享一下Entity Framework的CRUD操作,在这之前呢,老魏先说一下老魏对EF的一个整体的认识, ...
- php捕获网络页面
<?php $url = 'http://jwzx.cqupt.edu.cn/pubYxKebiao.php?type=zy&yx=06'; $html = file_get_conte ...
- 54.xilinx_modelsim仿真错误1
在仿真DDR3核时,用modelsim编译时会出现下面错误 Error:can't read "env(XILINX)":no such variable 原因:在.do文件中指定 ...