当前位置:网站首页>题目 1004: 母牛的故事(递推)
题目 1004: 母牛的故事(递推)
2022-07-01 12:35:00 【51CTO】
文章目录
- Question
- Ideas
- Code
Question
Ideas
第n年的牛数 = 第n-1年的牛数 + 第n-3年前的数目(小牛四年后可以生)
Code
# 递推
list
= []
#定义列表
list.
append(
0)
# 往list添加初始数据
list.
append(
1)
# 第一年奶牛数量为1
list.
append(
2)
# 第一年奶牛数量为2
list.
append(
3)
# 第一年奶牛数量为3
for
i
in
range(
4,
1000):
#预处理前1000年的奶牛数量
list.
append(
list[
i
-
1]
+
list[
i
-
3])
while
True:
n
=
int(
input())
#化为整型
if
n
==
0:
#n ==0 时退出
break
print(
list[
n])
#已经预处理了,所有直接输出就可以了
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
边栏推荐
- Teach you to complete the actual battle of image classification hand in hand -- Image Recognition Based on convolutional neural network
- redis探索之缓存一致性
- Compile and debug net6 source code
- Pandas reads MySQL data
- 本科毕业四年:工作,辞职,结婚,买房
- Four years after graduation: work, resign, get married, buy a house
- Like the three foot platform
- 循环链表--
- [Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 4
- Ansible的playbook
猜你喜欢

【datawhale202206】pyTorch推荐系统:召回模型 DSSM&YoutubeDNN

Onenet Internet of things platform - mqtt product equipment upload data points

codeforces -- 4B. Before an Exam

C serialization simple experiment
![[106] 360 check font - check whether the copyright of local Fonts is commercially available](/img/a7/615e8000647b56f03a6a1d3dd81b6d.jpg)
[106] 360 check font - check whether the copyright of local Fonts is commercially available
![[speech signal processing] 3 speech signal visualization -- prosody](/img/06/5f57f9dfe3a0f2f70022706f7d4d17.jpg)
[speech signal processing] 3 speech signal visualization -- prosody

双链表有关操作

VS Code 设置代码自动保存

Mobile note application
![[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 8](/img/16/e1a0a52964c8a55eb729469114fc60.jpg)
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 8
随机推荐
[Suanli network] technological innovation of Suanli Network -- key technology of operation service
ASTM D 3801固体塑料垂直燃烧试验
Relationship between accuracy factor (DOP) and covariance in GPS data (reference link)
Compile and debug net6 source code
【datawhale202206】pyTorch推荐系统:精排模型 DeepFM&DIN
腾讯安全发布《BOT管理白皮书》|解读BOT攻击,探索防护之道
"Analysis of 43 cases of MATLAB neural network": Chapter 40 research on prediction of dynamic neural network time series -- implementation of NARX based on MATLAB
手机便签应用
System test UI test summary and questions (interview)
被锡膏坑了一把
GPS 数据中的精度因子(DOP)与协方差之间的关系 (参考链接)
First intention is the most important
QT 播放器之列表[通俗易懂]
[JS] interview questions
《MATLAB 神经网络43个案例分析》:第40章 动态神经网络时间序列预测研究——基于MATLAB的NARX实现
ASP.NET Core 6 从入门到企业级实战开发应用技术汇总
2022-06-28-06-29
Tencent security released the white paper on BOT Management | interpreting BOT attacks and exploring ways to protect
[speech signal processing] 3 speech signal visualization -- prosody
编译调试Net6源码