当前位置:网站首页>AcWing 3433. Eat candy recursively | find rules
AcWing 3433. Eat candy recursively | find rules
2022-07-18 14:53:00 【Alkali!】
subject
https://www.acwing.com/problem/content/3436/
Ideas
The title is frightening at a glance
Suppose there is N N N A candy , Eat at least every day 1 1 1 individual , Eat at most 2 2 2 individual , Ask how many kinds of eating programs there are
Recursion can be used (DP) Methods :
I didn't expect such a simple answer
Code
#include<iostream>
using namespace std;
const int N=25;
int a[N];
int n;
int main()
{
a[0]=a[1]=1;
scanf("%d",&n);
for(int i=2;i<=n;i++) a[i]=a[i-1]+a[i-2];
printf("%d",a[n]);
return 0;
}
边栏推荐
- Go exceed API source code reading (I) -- newfile ()
- Wwdc22 - Apple privacy technology exploration
- Minimum interval problem
- Introduction to common controls of C form application
- Top k high frequency elements
- Design of hydrogen monitoring system based on single chip microcomputer (0490)
- LeetCode(剑指 Offer)- 03. 数组中重复的数字
- [C language] printf formatted output and modifier summary
- Antd a-upload limit the number of uploads when multiple is true
- Ask about the parallelism of MySQL source. The downstream parallelism of my source is 1. If I find that I can't turn on parallelism, I'll talk to you
猜你喜欢

Design of hydrogen monitoring system based on single chip microcomputer (0491)

The secret of black industry that the risk controller cannot know

Angr principle and Practice (I) -- principle

Design of intelligent speech recognition Bluetooth headset based on wtk6900h speech recognition single chip

thinkphp5.1.37反序列化链子分析

Conditional ternary operator...

2022T电梯修理操作证考试题及在线模拟考试

What if win11 prompts outlook for search errors? Win11 prompt outlook search error

STM32应用开发实践教程:具备交互功能的人机界面应用开发

小程序毕设作品之微信评选投票小程序毕业设计(6)开题答辩PPT
随机推荐
The degradation mechanism is not designed properly, and the online system crashes instantly
Variables in shell scripts
How to choose databases and tables and newsql?
2022年A特种设备相关管理(电梯)操作证考试题及在线模拟考试
小程序毕设作品之微信评选投票小程序毕业设计(5)任务书
全网首发独发:如何避免因为调用了没有实现的类方法而造成APP崩溃
分库分表和 NewSQL 到底怎么选?
后台运行程序方法
How to insert, delete and obtain random elements with constant time
学习路之PHP--post获取不到请求数据
03-GuliMall 开发环境配置
angr原理与实践(一)——原理
Desai wisdom number - discount (gradient stacking chart): per capita disposable income of national residents
Finding the median in data flow
Learning experience sharing 6: experience sharing of Dr. dry goods
Design of hydrogen monitoring and alarm system based on single chip microcomputer (0492)
去除重复字母(不同字符的最小序列)问题
Kotlin | 为 Kotlin 编译器任务推出构建报告
Minimum interval problem
antd a-upload 多选multiple为ture时 限制上传个数