Staircases
来源:互联网 发布:知乎钓鱼贴 编辑:程序博客网 时间:2024/06/02 21:38
1017. Staircases
Time limit: 1.0 second
Memory limit: 64 MB
Memory limit: 64 MB
One curious child has a set of N little bricks (5 ≤ N ≤ 500). From these bricks he builds different staircases. Staircase consists of steps of different sizes in a strictly descending order. It is not allowed for staircase to have steps equal sizes. Every staircase consists of at least two steps and each step contains at least one brick. Picture gives examples of staircase for N=11 andN=5:
Your task is to write a program that reads the number N and writes the only number Q — amount of different staircases that can be built from exactly N bricks.
Input
Number N
Output
Number Q
Sample
212
995645335
#include<iostream>#include<cstdio>using namespace std;typedef long long ll;#define maxn 505ll dp[maxn][maxn]= {0}; //dp[i][j] 表示有i个积木,最后一层不超过j个ll f[maxn]={0}; //利用生成函数(离散数学)int n;void read(){ scanf("%d",&n);}void DP(){ int i,j,k; dp[0][0]=1; for(i=0; i<maxn; i++) { for(j=1; j<=i; j++) dp[i][j]=dp[i-j][j-1]+dp[i][j-1]; for(k=i+1; k<maxn; k++) dp[i][k]=dp[i][i]; }}void Gx(){//G(x)=(1+x)*(1+x^2)*(1+x^3)*...(1+x^n) ,x^n的系数减1就是答案 int i,j,k; f[0]=1; for(i=1;i<maxn;i++) for(j=maxn-1;j>=i;j--) f[j]+=f[j-i];}void print(){ Gx(); cout<<f[n]-1<<endl; //DP(); //cout<<dp[n][n]-1<<endl;}int main(){ read(); print(); return 0;}
- Staircases
- Staircases
- 1017. Staircases
- zoj1163The Staircases
- JOJ 1026 The staircases
- 1026: The Staircases
- Ural 1017 The Staircases
- ural 1017 Staircases
- ZOJ 1163The Staircases
- zoj 1163 The Staircases
- ural 1017 Staircases
- zoj1163:The Staircases
- Timus 1017. Staircases
- ural 1017. The Staircases
- Ural 1017. Staircases
- B. Petya and Staircases
- URAL:1017 Staircases
- URAL 1017. Staircases
- -mfloat-abi=softfp的问题,指定fpu为neon
- [转]64位win7系统安装vs2010不成功的解决办法
- 声明与函数、函数指针
- UNIX网络编程——网络IPC:套接字
- Doing Homework again
- Staircases
- iOS利用代理实现界面跳转
- source insight在编辑C时"{"自动缩进的别扭规则的解决.
- UVA 11754 Code Feat 中国剩余定理+普通枚举
- 关系数据库表主键和外键
- SURF源码分析之surflib.h
- Android实现推送方式解决方案
- 博客更新
- stl的unique简单demo