Hdu 5366 The mook jong 公式求解

The mook jong

Time Limit: 2000/1000 MS (Java/Others)

Memory Limit: 65536/65536 K (Java/Others)

问题描述

ZJiaQ为了强身健体,决定通过木人桩练习武术。ZJiaQ希望把木人桩摆在自家的那个由1*1的地砖铺成的1*n的院子里。由于ZJiaQ是个强迫症,所以他要把一个木人桩正好摆在一个地砖上,由于木人桩手比较长,所以两个木人桩之间地砖必须大于等于两个,现在ZJiaQ想知道在至少摆放一个木人桩的情况下,有多少种摆法。

输入描述

输入有多组数据,每组数据第一行为一个整数n(1 < = n < = 60)

输出描述

对于每组数据输出一行表示摆放方案数

输入样例

1
2
3
4
5
6

输出样例

1
2
3
5
8
12
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>

typedef long long ll;
using namespace std;

const int INF=0x3f3f3f3f;
const int MAXN=100;

ll dp[MAXN];

int main()
{
	dp[1]=1;
	dp[2]=2;
	dp[3]=3;
	for(int i=4;i<=60;i++){
		dp[i]=dp[i-1]+dp[i-3]+1;
	}
	int n;
	while(cin>>n)cout<<dp[n]<<endl;
	return 0;
}

  

				
时间: 2024-10-26 00:53:42

Hdu 5366 The mook jong 公式求解的相关文章

HDU 5366 The mook jong

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5366 Problem Description ![](../../data/images/C613-1001-1.jpg) ZJiaQ want to become a strong man, so he decided to play the mook jong.ZJiaQ want to put some mook jongs in his backyard. His backyard con

HDU 5366 The mook jong (动态规划,详解)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5366 题面: The mook jong Accepts: 221 Submissions: 306 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description ZJiaQ want to become a strong man, so he decided

HDU - 5366 The mook jong (dp动态规划)

The mook jong Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 62    Accepted Submission(s): 40 Problem Description ![](../../data/images/C613-1001-1.jpg) ZJiaQ want to become a strong man, so h

hdu 5366 The mook jong dp

The mook jong Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 263    Accepted Submission(s): 200 Problem Description ![](../../data/images/C613-1001-1.jpg) ZJiaQ want to become a strong man, so

hdu 5366 The mook jong 动态规划(BC 50 C题)

比赛的时候还是没做出来,BC又是做一题,估计又是要掉分了,慢慢提升,总会终结一题的命运... 思路: 动态规划,然而我刚开始学,并不会做啊...先是找规律找了半天,结果啥也没找出来,又开始深搜, 结果样例能过,交上超时了,深度太大啊,没有正确估算...赛后看了题解,动态规划真是神算法啊,简单几行就 搞定了.设一个数组d[n]表示地板总数(n>3)然后列出状态转移方程d[n] = d[n-1] + (d[n-3] + 1);可以 这样理解,n是在n-1个地板上加上一个地板,我们可以对这个新增的地板

HDU 5366 The mook jong (简单DP)

题意:ZJiaQ希望把木人桩摆在自家的那个由1*1的地砖铺成的1*n的院子里.由于ZJiaQ是个强迫症,所以他要把一个木人桩正好摆在一个地砖上,由于木人桩手比较长,所以两个木人桩之间地砖必须大于等于两个,现在ZJiaQ想知道在至少摆放一个木人桩的情况下,有多少种摆法. 思路:题意类似于“要求找到所有满足这样要求的二进制的数:(1)不能出现101   (2)不能出现11  (3)不能为0”. 问题是可以降低规模的,也就是也可以递推,假设cnt[i][0]表示第i位放0的所有可能数,cnt[i][1

HDU 5336 The mook jong (DP)

The mook jong Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 217    Accepted Submission(s): 160 Problem Description ![](../../data/images/C613-1001-1.jpg) ZJiaQ want to become a strong man, so

HDU 5366:The mook jong 递推

The mook jong Accepts: 506 Submissions: 1281 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) 问题描写叙述 ZJiaQ为了强身健体.决定通过木人桩练习武术. ZJiaQ希望把木人桩摆在自家的那个由1*1的地砖铺成的1*n的院子里. 因为ZJiaQ是个强迫症,所以他要把一个木人桩正好摆在一个地砖上,因为木人桩手比較长.所以两个木人桩之间地砖必

hdu 5366 (bc #50 1003) The mook jong

The mook jong Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 269    Accepted Submission(s): 205 Problem Description ![](../../data/images/C613-1001-1.jpg) ZJiaQ want to become a strong man, so