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 ...
随机推荐
- Oracle EBS-SQL (WIP-4):检查检查成品标准作业是否勾选"固定"标识.sql
select WE.DESCRIPTION 任务说明, ...
- Delphi窗体最大化按钮不可用情况下的最大化
最大化按钮不可用,而且窗体最大化,我以前一直这样设置:在Object Inspector下把BorderIcons属性下的biMaximize属性设置为False,然后把WindowState属性设置 ...
- 一步一步学习SignalR进行实时通信_6_案例
原文:一步一步学习SignalR进行实时通信_6_案例 一步一步学习SignalR进行实时通信\_6_案例1 一步一步学习SignalR进行实时通信_6_案例1 前言 类的定义 各块功能 后台 上线 ...
- OpenGL红宝书学习笔记(1)
OpenGL对场景中的图像进行渲染时所执行的主要操作: 1.根据几何图元创建形状,从而建立物体的数学描述,(OpenGL把点,直线,多边形和位图作为基本的图元) 2.在三维空间中排列物体,并选择观察复 ...
- wx.button
wx.Button A button is a control that contains a text string, and is one of the most common elements ...
- SQL Server:SQL Like 通配符特殊用法:Escape 【转】
SQL中escape的主要用途 1.使用 ESCAPE 关键字定义转义符.在模式中,当转义符置于通配符之前时,该通配符就解释为普通字符.例如,要搜索在任意位置包含字符串 5% 的字符串 ...
- Hibernate的介绍
1.什么是Hibernate? 首先,Hibernate是数据持久层的一个轻量级框架.数据持久层的框架有非常多比方:iBATIS,myBatis,Nhibernate,Siena等等. 而且Hiber ...
- php 实现二进制加法运算
php实现二进制加法: 思路:没有工作中应用过此场景,但十进制的加法还是经常做的,能不能用十进制加法变相实现呢? 答案是可以的,并且php也提供进制间转换的函数,我的实现使用了 bindec():二进 ...
- .NET面试题解答
抽象类和接口有什么区别?使用时候有什么需要注意的吗?答:相同点:都不能被直接实例化,都通过继承实现其抽象方法: 不同点: 1) 接口支持多继承:抽象类不能实现多继承: 2) 接口只能定义行为:抽象类既 ...
- EcShop后台添加菜单[步骤]
1. 添加菜单的链接地址:打开文件[/后台目录/includes/inc_menu.php],在结尾加入例如:$modules['dashi']['dashi_list'] = 'join_dashi ...