The Fibonacci sequence of the Olympiad

Source: Internet
Author: User

Today the group out an algorithm problem, feel very funny, their elementary school when math, think can fix, think for a long time oneself still did not find solution, hey, it seems IQ still two times development. First, the topic:

50 steps, can walk 1 steps or 2 steps at a time, ask how many kinds of way?

See this question I first think of is with for, similar to 2 yuan money can have how many 1, 5 wool, 2 wool, 1 wool composition, but think carefully or not, steps this is in order, even if only one of the 50 steps is two steps there are several cases, so think first from the 2 steps of the count, up to 26 kinds, In these 26 kinds of order, so that the head is big. Fortunately, wisdom in the folk, the power of the masses Unlimited, Baidu, online has a solution, I looked under, and finally found out why I did not test Tsinghua University, IQ is flawed AH.

The online solution is: before going to the N steps, either walk 1 steps, or walk 2 steps, so f (n) =f (n-1) +f (n-2), very straightforward, but also very admire the IQ of netizens.

The Fibonacci sequence of the Olympiad

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.