The takeaway restaurant shows

Source: Internet
Author: User

Baidu Takeout "Nearby restaurant" shows a grid of N rows of 4 columns, which is originally occupied 1 rows of 1 row of square restaurant ads, the new designer du Bear is considering a new design, to better showcase the nearby restaurant.
Du Bear, as a designer, wants to put in a grid of N rows and 4 columns in front of a number of 1 rows and 1 columns of square restaurant ads, so that the rest of the space, can be accounted for 1 rows of 2 columns or 2 rows of 1 row restaurant ads perfect coverage. Du Bear wants you to help him determine how many square restaurant ads to put in place, so that the rest of the space after placing several square restaurant ads can be a number of 1 rows of 2 columns or 2 rows of 1 column restaurant ads perfect coverage.

The perfect coverage is that each location that is not placed in a square restaurant ad is overwritten by the bar, and the ad is not beyond the boundaries of the page (if all locations have been placed in a square restaurant ad is the perfect overlay).
Because of the number of scenarios, we want you to output the results of the 1,000,000,007 modulo for the number of scenarios.
Input format
Enter the first behavior of an integer T (1≤t≤20) that represents the number of data groups.
Next to a total T line, each behavior is a positive integer N (1≤n≤1018), which represents the length of the page.
For a simple version, 1≤n≤6;
For medium version, 1≤n≤1000;
For difficult versions, 1≤n≤1018.
Output format
Output a total of T-lines, each output the group of data corresponding to the number of scenarios to 1,000,000,007 modulo results.
Example 1
Input:
4
1
2
3
100
Output:
5
54
550
397280121
Prompt information
For the first set of data in the sample, there are 5 scenarios (1 rows and 1 columns of ads are labeled 1 and the remaining 0):
0000

1100

0011

1001

1111
For the above 5 scenarios, the remaining positions can be covered by 1 rows and 2 columns of ads.

 def func(lst,n):    ifMax (LST) >n:return 0    ifMax (LST) ==n andMin (LST) ==n:return 1K=min (LST) result=0     forIinchRange0,4):ifLst[i]==k:lstnext=lst.copy () lstnext[i]+=1Result+=func (Lstnext,n) lstnext=lst.copy () lstnext[i]+=2Result+=func (Lstnext,n)ifi+1<4  andlst[i+1]==k:lstnext=lst.copy () lstnext[i]+=1lstnext[i+1]+=1Result+=func (Lstnext,n)returnresultlst=[0  forIinchRange0,4)]n=int (input ()) forIinchRange0, N): K=int (Input ()) Print (Func (Lst.copy (), K))

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The takeaway restaurant shows

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.