当前位置:网站首页>AcWing 3433. 吃糖果 递推|找规律
AcWing 3433. 吃糖果 递推|找规律
2022-07-16 06:18:00 【Alkali!】
题目
https://www.acwing.com/problem/content/3436/
思路
题目猛一看很唬人啊
假设有 N N N个糖果,每天最少吃 1 1 1个,最多吃 2 2 2个,求一共有多少种吃的方案
可以采用递推(DP)的方法:
想不到这么简答啊
代码
#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;
}
边栏推荐
- How does DMS empower database functions?
- Methods and extensions of array objects, extension methods of strings, and traversal of arrays in ES6
- 网络安全实验:防火墙技术
- antd a-upload 多选multiple为ture时 限制上传个数
- WWDC22 - Apple 隐私技术探索
- STM32应用开发实践教程:基于 CAN 总线的多机通信应用开发
- Wechat selection and voting of applet completion works applet graduation project (8) graduation project thesis template
- Finding the median in data flow
- STM32应用开发实践教程:具备交互功能的人机界面应用开发
- 为什么电商平台要重点关注非法经营罪,这与二清又有什么关联?
猜你喜欢

Wechat selection and voting of applet completion works applet graduation design (5) assignment

Codeforces Global Round 21 D. Permutation Graph

Codeforces Round #804 A The Third Three Number Problem

全网首发独发:如何避免因为调用了没有实现的类方法而造成APP崩溃

Three cycle structure of Microcomputer Principle and technology interface experiment

小程序毕设作品之微信评选投票小程序毕业设计(5)任务书

6. Redis architecture design to use scenarios - persistence mechanism, cache invalidation strategy, cache hit rate

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

UE adds two buttons on the resource right-click menu of editor

2022危险化学品经营单位安全管理人员操作考试题及答案
随机推荐
分糖果系列问题
The secret of black industry that the risk controller cannot know
Leetcode (Sword finger offer) - 03 Duplicate numbers in array
2022年R2移动式压力容器充装试题及答案
ViewGroup event distribution sorting
How to insert, delete and obtain random elements with constant time
A series of questions about candy
Go exceed API source code reading (I) -- newfile ()
How to solve the problem of high concurrency? You will understand it completely after reading it.
Codeforces Round #803 (Div. 2) A. XOR Mixup
vivado里那些看不懂的约束语句
Design of hydrogen monitoring system based on single chip microcomputer (0490)
Codeforces Round #805 A - G
降级机制设计不当,线上系统瞬间崩溃...
通过装饰器获取调用函数的文件名称及函数名称
STM32 application development practice tutorial: multi computer communication application development based on CAN bus
STM32 general timer
Finding the median in data flow
How does DMS empower database functions?
How to turn off win11 system protection? Win11 system protection shutdown method