2277 爱吃皮蛋的小明

 

 时间限制: 1 s
 空间限制: 32000 KB
 题目等级 : 白银 Silver
 
 
题目描述 Description

小明特别爱吃蛋,特别是皮蛋。他一次可以吃一个蛋或者两个蛋(整个吞下去),而且他喜欢吃得有花样,他想知道对于一定蛋的数量,有几种不同的吃法。

输入描述 Input Description

一行一个整数N,表示皮蛋的数量

输出描述 Output Description

一行一个整数sum,表示吃法总数

样例输入 Sample Input

3

样例输出 Sample Output

3

 

说明:有以下3种吃法

(1+1+1)

(1+2)

(2+1)

数据范围及提示 Data Size & Hint

0<N≤90

分类标签 Tags 

 

 1 #include<iostream>
 2 using namespace std;
 3 long long int a[10000001];
 4 int main()
 5 {
 6     int n;
 7     a[1]=1;
 8     a[2]=2;
 9     cin>>n;
10     for(int i=3;i<=n;i++)
11     {
12         a[i]=a[i-1]+a[i-2];
13     }
14     cout<<a[n];
15     return 0;
16 }

 

相关文章:

  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
  • 2021-08-08
  • 2021-07-12
  • 2021-11-08
  • 2022-02-10
  • 2022-12-23
猜你喜欢
  • 2021-11-20
  • 2022-12-23
  • 2021-07-17
  • 2021-08-20
  • 2022-01-25
  • 2021-08-11
  • 2021-09-22
相关资源
相似解决方案