题解 | 吃糖果

吃糖果

https://www.nowcoder.com/practice/72015680c32b449899e81f1470836097

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int ans[30]={0};
int main() {
    int N;
    cin>>N;
    ans[1]=1;
    ans[2]=2;
    for(int i=3;i<=N;i++)
    {
        ans[i] = ans[i-1]+ans[i-2];
    }
    cout<<ans[N]<<endl;


}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

点赞 评论 收藏
分享
勇敢的90后想交流:我愿意付费上班,楼主你就安心字节待着吧,我是真的喜欢上班
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务