• 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 <iostream>
     2 #include <cstdlib>
     3 #include <cstdio>
     4 #include <algorithm>
     5 #include <vector>
     6 #include <queue>
     7 #include <cmath>
     8 #include <stack>
     9 #include <cstring>
    10 
    11 using namespace std;
    12 
    13 #define INF 0xfffffff
    14 #define maxn 10005
    15 
    16 int main()
    17 {
    18     __int64 n, dp[maxn] = {1, 2, 3, 5};
    19 
    20     while(scanf("%I64d", &n) != EOF)
    21     {
    22         for(int i = 3; i <= n; i++)
    23             dp[i] = dp[i-3] + dp[i-1];
    24         printf("%I64d
    ", dp[n]-1);  // 减去一种什么都不放的情况
    25 
    26     }
    27     return 0;
    28 }
    让未来到来 让过去过去
  • 相关阅读:
    Aria2任意文件写入漏洞
    webpack添加node_path不是('webpack' 不是内部或外部命令,也不是可运行的程序或批处理文件?)
    闭包的7种形式
    首页 多级展示
    velocity模板入门
    AngularJs 时间控件
    mybatis按时间条件搜索
    数据结构之线性表(双向循环链表)
    数据结构之线性表(链表)
    数据结构之线性表(顺序表)
  • 原文地址:https://www.cnblogs.com/Tinamei/p/4717194.html
Copyright © 2020-2023  润新知