• 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
    ",dp1[n]+dp2[n]-1);
    21     }
    22     return 0;
    23 }
    View Code
  • 相关阅读:
    bzoj2732[HNOI2012]射箭
    poj1474 Video Surveillance
    bzoj3167[HEOI2013]SAO
    hdu2296 Ring
    bzoj2119 股市的预测
    bzoj2244[SDOI2011]拦截导弹
    bzoj3502[PA2012]Tanie Linie(最大k区间和)
    vijos1859[TJOI2014]电源插排
    比较SQL查询性能 语句
    什么是高内聚低耦合
  • 原文地址:https://www.cnblogs.com/cyd308/p/4771336.html
Copyright © 2020-2023  润新知