当前位置:网站首页>The recursive recursive Fighting_ silver study ah but level 4
The recursive recursive Fighting_ silver study ah but level 4
2022-08-10 13:21:00 【51CTO】
Approximate title:
There are n seats in a row, and at least two seats are vacant between every two people, and the practice in the case of at least one person is required.
Thinking:
a[n] is all practices that have n seats.Assuming that the previous actions have been arranged, there are two situations for the nth seat, someone does it and no one does it. When someone does it, n-1 and n-2 must be done by no one, so the sitting method and a[n-3] is the same, when no one is sitting, it is the same as sitting on a[n-1], but there is another case, that is, when there is only one person sitting, on a[n]Sitting by one person is also considered a situation, so the formula a[n]=a[n-1]+a[n-3]+1 is obtained.
Thinking:
This question is a bit difficult to think about, but it is not difficult to think that all the sitting methods can be deduced by formula, and generally the latter data is related to the former, but it is easy to add one at the endForget it, but when debugging, you will find that each number will be smaller by 1, and if you think about it carefully, you will find the error.
Code:
边栏推荐
猜你喜欢
mSystems | 中农汪杰组揭示影响土壤“塑料际”微生物群落的机制
Prada, big show?In the yuan in the universe that!
2022 Recruitment Notice for Academician Zhao Guoping Group of Shenzhen Institute of Advanced Technology, Chinese Academy of Sciences
一个 CRM One Order Application log 的单元测试报表
kubernetes介绍
LeetCode medium topic search of two-dimensional matrix
2022年8月中国数据库排行榜:openGauss重夺榜眼,PolarDB反超人大金仓
线代 | 秒杀方法与技巧
LeetCode中等题之颠倒字符串中的单词
Efficient and Robust 2D-to-BEV Representation Learning via Geometry-guided Kernel Transformer 论文笔记
随机推荐
协程与任务
es6-promise对象详解
C# error The 'xmins' attribute is not supported in this context
3DS MAX 批量导出文件脚本 MAXScript 带界面
娄底植物细胞实验室建设基本组成要点
Reversing words in a string in LeetCode
How to describe multiple paragraphs with different font settings in Open Office XML format
jenkins数据迁移和备份
娄底干细胞制备实验室建设须知要求
表中存在多个索引问题? - 聚集索引,回表,覆盖索引
海外邮件发送指南(二)
DNS欺骗-教程详解
Open Office XML 格式里如何描述多段具有不同字体设置的段落
The basic components of Loudi plant cell laboratory construction
Keithley DMM7510 accurate measurement of ultra-low power consumption equipment all kinds of operation mode power consumption
【iOS】面试整理
shell:正则表达式及三剑客grep命令
C# 当前上下文中不存在InitializeComponent()
递归递推之Fighting_小银考呀考不过四级
Requirements for the construction of Loudi stem cell preparation laboratory