-
Title Description:
-
The name of the mother from the field back, with a box of delicious and beautiful chocolate to the name (the box has a total of n blocks of chocolate, > N >0).
Mom tells the name to eat one or two chocolates a day.
Let's say the name has chocolate every day, and how many different kinds of chocolate-eating programs are in the name.
For example:
If the n=1, then the name of the 1th day to eat it, a total of 1 options;
If n=2, then the name can eat 1 yuan on the 1th day, eat 1 yuan on the 2nd day, also can eat 2 pieces on 1th Day, a total of 2 kinds of programs;
If n=3, the name of the 1th day can eat 1 pieces, left 2 pieces, can also eat 1th Day 2 pieces left 1 pieces, so the name of a total of 2+1=3 species scheme;
If n=4, then the name can eat 1 yuan on the 1th day, the remaining 3, can also eat the 1th Day 2, left 2 pieces, a total of 3+2=5 species scheme.
Now given n, ask you to write a program to find out the number of famous chocolate-eating programs.
-
Input:
-
Input is only 1 lines, that is, integer n.
-
Output:
-
There may be multiple sets of test data, for each set of data,
The output is only 1 lines, that is, the number of programs that the name eats chocolate.
-
Sample input:
-
4
-
Sample output:
-
5
-
Source:
-
2008 the computer research of the graphics Laboratory of Peking University the real problem
-
#include <iostream> //The problem is actually a Fibonacci sequence 112358......using namespace std;int f (int n) { if (n==1) { return 1; } else if (n==2) { return 2; } else return F (n-1) +f (n-2);} int main () { int x; while (cin>>x) { cout<<f (x) <<endl; } return 1;} /************************************************************** problem:1122 User:carvin language:c++ result:accepted time:10 ms memory:1520 kb******************************************* *********************/
Topic 1122: Eating sweets