HDU 5366 The mook jong

Posted Reqaw’s Blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 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
题意描述:
输入砖数n( 1 < = n < = 60)
计算并输出有多少种合法的放器材的方法(至少有一个器材)
解题思路:
首先想到的是数据范围是1到60,打表解决。
具体打表过程中刚开始想的是有一个公式计算,就一直在总结那个公式,花费了好多时间,其实这种题直接列出来找规律递推即可。
另外,最好将数组定义为long long不容易溢出,也更为保险。
AC代码:
 1 #include<stdio.h>
 2 int main()
 3 {
 4     int n,sum,i;
 5     long long f[60];//int类型55以上出现错误,改为long long 
 6     f[1]=1;
 7     f[2]=2;
 8     f[3]=3;
 9     for(i=4;i<=60;i++)
10         f[i]=f[i-1]+f[i-3]+1;
11     while(scanf("%d",&n) != EOF)
12     {
13         printf("%lld\n",f[n]);
14     }
15     return 0;
16 }

 

 
 

以上是关于HDU 5366 The mook jong的主要内容,如果未能解决你的问题,请参考以下文章

HDU 5366:The mook jong 递推

HDU-1561 The more, The Better (树形DP+分组背包)

The service already exists! The current server installed: D:mysqlmysql-5.7.30-winx64inmysqld My(代码片

MOOK学习

ASP.NET MVC 复制MVC项目代码到同一个项目的时候报错The request for ‘home’ has found the following matching controll(代码片

Warning: Permanently added the RSA host key for IP address ‘13.250.177.223‘ to the list of known(代码片