Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Must be written in C++, thanks!: Your librarian has a 2-row bookshelf that can contain N books in each row. She wants to know the

Must be written in C++, thanks!:

Your librarian has a 2-row bookshelf that can contain N books in each row. She wants to know the number of ways that she can fill the bookshelf with red-colored books and blue-colored books such that no 2 red-colored books are adjacent to each other (horizontally or vertically).

Input: the integer, N (1<=N<=2^1024)

Output: the number of ways you can place red-colored books and blue-colored books onto a N-column bookshelf. Since this number might be really big, output it mod 10^9+7.

Example: Input: 2

Your valid bookshelf layouts are:

BB BB BB BR BR BB RB BB BB RB RB BR BR RB 

Therefore, Output: 7

You do not need to output the bookself layout letters, just the number of ways you can place red-colored books and blue-colored books onto a N-column bookshelf.

Input is whatever the user puts, could be 5, could be 30, could be whatever integer.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

10. Revise the draft in a repeated fashion.

Answered: 1 week ago