1944: Eating sweets
- View
- Submit
- Statistics
- Questions
-
Total time limit:
-
1000ms
-
Memory Limit:
-
65536kB
-
-
Describe
-
-
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 N=1, then the name of the 1th day to eat it, a total of 1 kinds of programs; if n=2, then the first name can eat the 1th day of 1, the 2nd day to eat 1, can also be 1th day to eat 2 pieces, a total of 2 programs; if n=3, then the name 1th Day can eat 1 pieces, 2 blocks left, can also 1th 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, 3 pieces left, you can also eat the 1th Day 2, 2 pieces left, a total of 3+2=5 schemes. 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
-
-
the output is only 1 lines, that is, the number of programs that the name eats chocolate.
-
-
Sample input
-
-
4
-
-
Sample output
-
5
#include <cstdio>#defineRef (I,X,Y) for (register int i=x;i<=y;i++)using namespacestd;intf[Wuyi];intN,m,t,ans;intMain () {f[0]=1; f[1]=1; scanf ("%d",&N); refI2, N) f[i]=f[i-1]+f[i-2]; printf ("%d\n", F[n]); return 0;}
1944: Eating Sweets (Fibonacci series)