当前位置:网站首页>Leetcode: dynamic planning template
Leetcode: dynamic planning template
2022-07-03 03:32:00 【My family Dabao is the cutest】
1. Count rabbits
There is a rabbit , From the day after birth 3 A rabbit has been born every month since last month , The little rabbit grows to the third month and gives birth to another rabbit every month , If the rabbits don't die , Ask the total number of rabbits per month ?
Let's assume that No n-2 When I was six months old dp[n-2] A rabbit , The first n-1 When I was six months old dp[n-1] A rabbit , So the first n How many rabbits are there in a month ? The first n A month old rabbit must have a first n-1 A month old rabbit came , So at least dp[n-1] A rabbit , But at the same time , Rabbits born two months old will have another rabbit . How many rabbits are there two months old ? The rabbit that is pushed forward for two months is the rabbit that is currently born for two months ( Nonsense Literature ), So the number of rabbits born two months is dp[n-2] individual , These rabbits will already be included dp[n-1] In , But they will also have dp[n-2] A rabbit , therefore dp[n]=dp[n-1]+dp[n-2].
Rabbits two months ago will have a rabbit , How many rabbits were there two months ago ? The answer is dp[n-2], Rabbits one month ago will also be classified as next month 
边栏推荐
- Gavin teacher's perception of transformer live class - rasa project's actual banking financial BOT Intelligent Business Dialogue robot architecture, process and phenomenon decryption through rasa inte
- Pat class B common function Usage Summary
- Download and install node, NPM and yarn
- QQ小程序开发之 一些前期准备:预约开发账号、下载安装开发者工具、创建qq小程序
- [mathematical logic] normal form (conjunctive normal form | disjunctive normal form | major item | minor item | maximal item | minor item | principal conjunctive normal form | principal disjunctive no
- Limit of one question per day
- 二进制流转换成字节数组
- Section 26 detailed explanation and demonstration of IPSec virtual private network configuration experiment - simulation experiment based on packettracer8.0
- Nanning water leakage detection: warmly congratulate Guangxi Zhongshui on winning the first famous brand in Guangxi
- The file marked by labelme is converted to yolov5 format
猜你喜欢

The idea setting code is in UTF-8 idea Properties configuration file Chinese garbled

Vs 2019 configuration tensorrt

Téléchargement et installation du client Filezilla

Applet get user avatar and nickname

MySQL MAC download and installation tutorial
![Learning notes of C programming [compiled by Mr. Tan Haoqiang] (Chapter III sequence programming) 04 C sentence](/img/60/bae0e8d92a53bcd2b2de3fb22b3b99.jpg)
Learning notes of C programming [compiled by Mr. Tan Haoqiang] (Chapter III sequence programming) 04 C sentence

Avec trois. JS fait une scène 3D simple

Ansible简介【暂未完成(半成品)】

Bid farewell to artificial mental retardation: Mengzi open source project team received RMB 100 million financing to help NLP develop

ffmpeg下载安装教程及介绍
随机推荐
[pyg] understand the messagepassing process, GCN demo details
[leetcode question brushing day 34] 540 Unique element in array, 384 Disrupt array, 202 Happy number, 149 Maximum number of points on a line
Introduction to mongodb
VS 2019安装及配置opencv
FileZilla client download and installation
递归:快速排序,归并排序和堆排序
PAT乙级“1104 天长地久”DFS优化思路
[algebraic structure] group (definition of group | basic properties of group | proof method of group | commutative group)
Converts a timestamp to a time in the specified format
MongoDB基本操作【增、删、改、查】
@The difference between Autowired, @qualifier, @resource
C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 05 data input and output
softmax的近似之NCE详解
User value is the last word in the competition of mobile phone market
Vs Code configure virtual environment
Summary of determinant knowledge points in Chapter 1 of Linear Algebra (Jeff's self perception)
[mathematical logic] propositional logic (propositional logic reasoning | formal structure of reasoning | inference law | additional law | simplification law | hypothetical reasoning | refusal | disju
@Accessors注解作用指定前缀遵守驼峰命名
Elsevier latex submitted the article pdftex def Error: File `thumbnails/cas-email. jpeg‘ not found: using draf
The file marked by labelme is converted to yolov5 format