1944: Eating Sweets (Fibonacci series)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.