A variant of the Fibonacci sequence on practical issues

Source: Internet
Author: User

We can use the small rectangle of 2*1 to cover the larger rectangle horizontally or vertically. Can you tell me how many methods 1 use the array structure traversal method if the small rectangle with n 2*1 covers a 2*n large rectangle without overlapping (target==1 | |  target==0)             return 1;         int [] arr = new int [target+1];             arr[0] = 1;             arr[1] = 1;         for (int i=2;i<=target;i++) {             arr[i] = arr[i-1]+arr[i-2];        }  &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;RETURN&NBSP;ARR[TARGET];2 uses two int variables and a temporary variable in a while statement without the help of the array structure temp    If (target==1 | |  target==0)             return 1;         int num1 = 1,num2 = 1;         while (target>1) {             Int temp = num2;            num2  +=num1;            num1=temp;             target--;         }        return num2;    3 recursive efficiency minimum         if (target==1 | |  target==0)             return 1;         if (target>1)              return rectcover (target-1) +rectcover (target-2);         return 0; here because of the use of OJ, when I above the   if (target==1 | |  target==0)             return 1; wrote a   if (target==1)             return 1;   if (target==0)             return 1;  if (target>1)             return  Rectcover (target-1) +rectcover (target-2);         return 0;o J System on the judgment time has timed out and really think about the problem that can be judged once, why do you want two times?

A variant of the Fibonacci sequence on a practical issue

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.