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): 16028 Accepted Submission(s): 11302
"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!"

#include<stdio.h>
const int MAXN=;
int main(){
int a[MAXN],b[MAXN],N;
while(~scanf("%d",&N)){
int i,j,k;
for(i=;i<=N;i++){
a[i]=;b[i]=;
}
for(i=;i<=N;i++){
for(j=;j<=N;j++)
for(k=;k+j<=N;k+=i)
b[j+k]+=a[j];
for(j=;j<=N;j++)
a[j]=b[j],b[j]=;
}
printf("%d\n",a[N]);
}
return ;
}
extern "C++"{
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
const int INF = 0x3f3f3f3f;
#define mem(x,y) memset(x,y,sizeof(x))
typedef long long LL;
typedef unsigned long long ULL;
void SI(int &x){scanf("%d",&x);}
void SI(double &x){scanf("%lf",&x);}
void SI(LL &x){scanf("%lld",&x);}
void SI(char *x){scanf("%s",x);}
}
const int MAXN = ;
int a[MAXN],b[MAXN];
int main(){
int N;
while(~scanf("%d",&N)){
for(int i = ;i <= N;i++)a[i] = ,b[i] = ;
for(int i = ;i <= N;i++){
for(int j = ;j <= N;j++){
for(int k = ;j + k <= N;k += i){
b[j + k] += a[j];
}
}
for(int j = ;j <= N;j++)a[j] = b[j],b[j] = ;
}
printf("%d\n",a[N]);
}
return ;
}
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 ...
- 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 ...
- 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 ...
- Ignatius and the Princess III HDU - 1028 || 整数拆分,母函数
Ignatius and the Princess III HDU - 1028 整数划分问题 假的dp(复杂度不对) #include<cstdio> #include<cstri ...
- HDOJ 1028 Ignatius and the Princess III (母函数)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- HDU1028 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(杭电1028)(母函数)
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- 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 ...
- Ignatius and the Princess III
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
随机推荐
- 1016. 部分A+B
/* * Main.c * 1016. 部分A+B * Created on: 2014年8月30日 * Author: Boomkeeper *******测试通过********* */ #inc ...
- Mindjet 一打开鼠标就动不了解决方法
在网上查找了一下相关资料,这个主要是Mindjet不支持64位系统造成的,其实就和Windows tablet pc input 这个服务相冲突造成的,临时的解决方法是,win+r (别告诉我你不知道 ...
- EasyList China国内镜像
镜像地址: http://www.ikay.me/list/easylistchina.txt 与官方服务器每15分钟同步一次 本文固定链接: http://www.ikay.me/easylistc ...
- Highways(求最小生成树的最大边)
Highways Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Total Sub ...
- C#.NET学习笔记1---C#.NET简介
C#.NET学习笔记1---C#.NET简介 技术qq交流群:JavaDream:251572072 教程下载,在线交流:创梦IT社区:www.credream.com -------------- ...
- [UI]抽屉菜单DrawerLayout分析(二)
继续分析DrawerLayout的手势分发部分 谈到手势分发,这本身就是个好话题,DrawerLayout作为继承自ViewGroup得布局他可以拦截手势也可以分发给子view,也就是在 onInte ...
- ListBox第一行字体比其他行小
ListBox第一行字体比其他行小,把字体设置成“宋体”就可以了.
- T-SQL查询:语句执行顺序
读书笔记:<Microsoft SQL Server 2008技术内幕:T-SQL查询> =============== T-SQL查询的执行顺序 =============== === ...
- 自定义配置文件的使用(web.config/app.config)
以下非原创作品,但都是自己看过理解并写过,记录下来,以便之后项目的使用或其它用途. (1)只需要简单配置单一属性值: <configuration> <configSections& ...
- NOIP2012模拟试题 121105【奶牛排队(tahort)
3.奶牛排队(tahort) [ 问题描述] 奶牛在熊大妈的带领下排成了一条直队. 显然,不同的奶牛身高不一定相同…… 现在,奶牛们想知道,如果找出一些连续的奶牛,要求最左边的奶牛A是最矮的,最右边的 ...