BC#50 1003 The mook jong

The mook jong

Accepts: 506

Submissions: 1281

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 to play the mook jong。ZJiaQ want to put some mook jongs in his backyard. His backyard consist of n bricks that is 1*1,so it is 1*n。ZJiaQ want to put a mook jong in a brick. because of the hands of the mook jong, the distance of two mook jongs should be equal or more than 2 bricks. Now ZJiaQ want to know how many ways can ZJiaQ put mook jongs legally(at least one mook jong).

Input

There ar multiply cases. For each case, there is a single integer n( 1 < = n < = 60)

Output

Print the ways in a single line for each case.

Sample Input

1
2
3
4
5
6

Sample Output

1
2
3
5
8
12

 1 #include <stdio.h>
 2 #include <string.h>
 3 int main()
 4 {
 5     long long n;
 6     long long dp1[66],dp2[67];
 7     int i,j,k;
 8     while(scanf("%I64d",&n)!=EOF)
 9     {
10         memset(dp1,0,sizeof(dp1));
11         memset(dp2,0,sizeof(dp2));
12         dp1[1]=1,dp2[1]=1;
13         dp1[2]=2,dp2[2]=1;
14         dp1[3]=3,dp2[3]=1;
15         for(i=4;i<=n;i++)
16         {
17             dp1[i]=dp1[i-1]+dp2[i-1];
18             dp2[i]=dp1[i-3]+dp2[i-3];
19         }
20         printf("%I64d\n",dp1[n]+dp2[n]-1);
21     }
22     return 0;
23 }

时间: 2024-10-09 12:53:10

BC#50 1003 The mook jong的相关文章

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

DP BestCoder Round #50 (div.2) 1003 The mook jong

题目传送门 1 /* 2 DP:这题赤裸裸的dp,dp[i][1/0]表示第i块板放木桩和不放木桩的方案数.状态转移方程: 3 dp[i][1] = dp[i-3][1] + dp[i-3][0] + 1; dp[i][0] = dp[i-1][1] + dp[i-1][0]; 4 比赛时二维dp写搓了,主要是边界情况的判断出错,比如dp[3][1] = 1,因为第3块放了木桩,其他地方不能再放,dp[3][0]同理 5 解释一下dp[i][1]的三种情况,可能是前面相隔2个放的方案或者是不放的

hdu5306The mook jong(简单递推)

BC #50#简单递推 看了很多讲解的递推没有很懂,还好zzuspy思路简单清晰: f(n):要放n个木桩,先考虑最后一个板砖如果放的话,the last one的前两个并不能放木桩,所以前n-3个板砖如果放木桩的话有f(n-3)中方案,如果不放木桩的话,有一种方案: 最后一个板砖如果不放的话,是f(n-1)中方案: 所以f(n)=f(n-1)+f(n-3)+1; 还有一个hack点是爆Int的问题,但是比赛时并没有找到可以hack的代码T-T The mook jong Accepts: 50

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 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 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

题目链接: 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

The mook jong 计数DP

The mook jong ZJiaQ为了强身健体,决定通过木人桩练习武术.ZJiaQ希望把木人桩摆在自家的那个由1*1的地砖铺成的1*n的院子里.由于ZJiaQ是个强迫症,所以他要把一个木人桩正好摆在一个地砖上,由于木人桩手比较长,所以两个木人桩之间地砖必须大于等于两个,现在ZJiaQ想知道在至少摆放一个木人桩的情况下,有多少种摆法. 输入描述 输入有多组数据,每组数据第一行为一个整数n(1 < = n < = 60) 输出描述 对于每组数据输出一行表示摆放方案数 1 #include &l

The mook jong

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 consist of n bricks that is 1*1,so it is 1*n.ZJiaQ want to put a mook jong in a brick. because of the hands of the