Tiles problem

0

0 votes
Problem

Problem Statement

You have been given a board where there are '2' rows and 'N' columns. You have an infinite supply of 2x1 tiles, and you can place a tile in the following ways:

1. Horizontally as 1x2 tile 2. Vertically as 2x1 tile

Count the number of ways to tile the given board using the available tiles.

Note :

The number of ways might be large so output your answer modulo 10^9 + 7.

Here is an example of tile and board for 'N' = 4 :

Input Format :

The first and only line of each test case contains an Integer 'N' which denotes the size of the board, i.e. '2' rows and 'N' columns.

Output Format :

For each test case, print the number of ways to tile the board modulo 10^9 + 7.

Note: You are not required to print the output explicitly, You just need to implement the function.

Constraints :

1 <= N <= 10^18 Where 'N' is the number of columns in the board.

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

There are three ways for a 2*3 board,:

1. Place all 3 tiles vertically.

2. Place first tile vertically and remaining 2 tiles horizontally.

3. Place first 2 tiles horizontally and remaining tiles vertically.

Editor Image

?