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

Source

BestCoder Round #50 (div.2)

数学题...

f[i]=f[i-1]+f[i-3]+1

并不知道这个式子怎么推出来的.

我做的比较麻烦==

/*************************************************************************
    > File Name: code/bc/#50/1003.cpp
    > Author: 111qqz
    > Email: [email protected]
    > Created Time: 2015年08月08日 星期六 19时22分23秒
 ************************************************************************/

#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<stack>
#define y0 abc111qqz
#define y1 hust111qqz
#define yn hez111qqz
#define j1 cute111qqz
#define tm crazy111qqz
#define lr dying111qqz
using namespace std;
#define REP(i, n) for (int i=0;i<int(n);++i)
typedef long long LL;
typedef unsigned long long ULL;
const int inf = 0x7fffffff;
LL ans [100];
LL c[70][70];
LL sum[70][70];
int n;
void init()
{
    memset(c,0,sizeof(c));
    memset(sum,0,sizeof(sum));
    c[2][1]=1;
    c[2][2]=3;
    c[2][3]=6;
    sum[2][1] = 0;
    for ( int i = 1 ; i <= 61 ; i++ )
    {
    c[2][i]=(i)*(i+1)/2;
    sum[2][i]=sum[2][i-1]+c[2][i];
    }
    for ( int i = 3 ; i <= 61 ; i ++)
    {
    for ( int j = 1 ; j <= 61-i ; j++)
    {
        c[i][j]=sum[i-1][j];
        sum[i][j]=sum[i][j-1]+c[i][j];
    }
    }

}
LL solve ( int x)
{
    LL res  = x;
    LL rm;
    LL rem;
    for ( int i = 2; i <= (x+2)/3; i ++)  //摆放的个数
    {
    rm = x - (3*i-2);
    res = res + c[i][rm+1];
    }
    return res;
}
int main()
{
    init();
    for ( int i = 1 ; i <= 61 ; i ++ )
    {
    ans[i] = solve (i);
    }
    while (scanf("%d",&n)!=EOF)
    {
    cout<<ans[n]<<endl;
    }

    return 0;
}
时间: 2024-11-08 21:30:11

hdu 5366 (bc #50 1003) The mook jong的相关文章

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

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个放的方案或者是不放的

hdu 5364 (bc#50 1001) Distribution money

Distribution money Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 276    Accepted Submission(s): 163 Problem Description AFA want to distribution her money to somebody.She divide her money into

hdu 5365 (bc #50 1002 )Run

Run Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 594    Accepted Submission(s): 265 Problem Description AFA is a girl who like runing.Today,he download an app about runing .The app can record

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

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

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