当前位置:网站首页>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:
边栏推荐
- Nanodlp v2.2/v3.0光固化电路板,机械开关/光电开关/接近开关的接法和系统状态电平设置
- Prada, big show?In the yuan in the universe that!
- Educational Codeforces Round 41 (Rated for Div. 2) E. Tufurama
- 【黑马早报】雷军称低谷期曾想转行开酒吧;拜登正式签署芯片法案;软银二季度巨亏230亿美元;北京市消协约谈每日优鲜...
- es6-promise对象详解
- 啥?他一个人写了个价值100万的软件,却用来开源了!
- 娄底污水处理厂实验室建设管理
- wirshark 常用操作及 tcp 三次握手过程实例分析
- bgp dual plane experiment routing strategy to control traffic
- 【iOS】Organization of interviews
猜你喜欢
随机推荐
Reversing words in a string in LeetCode
Ethernet channel Ethernet channel
C# InitializeComponent() does not exist in the current context
Requirements for the construction of Loudi stem cell preparation laboratory
广东10个项目入选工信部2021年物联网示范项目名单
Inventory of Loudi Agricultural Products Inspection Laboratory Construction Guidelines
需要被记录的OpenStack相关的命令_自己用
Nanodlp v2.2/v3.0 light curing circuit board, connection method of mechanical switch/photoelectric switch/proximity switch and system state level setting
Have you guys encountered this problem?MySQL 2.2 and 2.3-SNAPSHOT are like this, it seems to be
Keithley DMM7510 accurate measurement of ultra-low power consumption equipment all kinds of operation mode power consumption
Polygon zkEVM工具——PIL和CIRCOM
一文详解 implementation api embed
iTextSharp操作PDF
MySQL索引的B+树到底有多高?
【mysql索引实现原理】
金山云要飘到哪里?
Fragment-hide和show
“68道 Redis+168道 MySQL”精品面试题(带解析)
九宫格抽奖动效
神了!阿里数据库专家纯手写了这份604页的Oracle+MySQL攻坚指南