HDU 1028 Ignatius and the Princess III

//强行递推。 xx[i][j]表示i数中第j个开头的组合种类。

/*

最终结果[i]为 sum of(xx[i][j])  (j from 1  to i);

 

xx[i][j]=sum of (xx[i-j][k])  (k from 1  to j);

例如 xx[10][4]=xx[6][1]+xx[6][2]+xx[6][3]+xx[6][4];

xx[6][1] =1;

6=1+1+1+1+1+1;

xx[6][2]=3;

6=2+2+2,

6=2+2+1+1,

6=2+1+1+1+1;

xx[6][3]=3;

6=3+3,

6=3+2+1,

6=3+1+1+1;

xx[6][4]=2;

6=4+2,

6=4+1+1;

xx[10][4]=xx[6][1]+xx[6][2]+xx[6][3]+xx[6][4]=9;

10=4+(1+1+1+1+1+1),

10=4+(2+2+2),

10=4+(2+2+1+1),

10=4+(2+1+1+1+1),

10=4+(3+3),

10=4+(3+2+1),

10=4+(3+1+1+1),

10=4+(4+2),

10=4+(4+1+1);

 

*/

#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdlib>
#include<vector>
#include<map>
#include<string>
#include<iostream>
#include<algorithm>
#define ull unsigned long long
#define ll long long
using namespace std;
#define INF 0x3F3F3F3F
int xx[125][125]={0};
int main()
{
int n;
for(int i=1;i<=120;i++)
{
xx[i][i]=1;
for(int j=i-1;j>=1;j--)
{
for(int k=1;k<=j;k++)
xx[i][j]+=xx[i-j][k];
}
}
while(~scanf("%d",&n))
{
int sum=0;
for(int i=1;i<=n;i++)
{
sum+=xx[n][i];
}
printf("%d\n",sum);
}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值