TopcoderArchiveVisit Topcoder
TCO26 Mar 2014
TCO 2014 Semifinal 2

PlankTiling

Problem statement, definition, constraints, and public examples.

Problem Statement

You have a sufficient supply of identical planks. Each plank has the shape of an 1 times H rectangle.


The floor of your room is also a rectangle. Its width is W and its height is 2H-1. You want to use the planks you have to tile the floor. The entire floor must be covered and the planks must not overlap. (The width W is guaranteed to be a multiple of H, so this is always possible.)


You are given the two ints H and W. Return the number of ways to tile the floor, modulo 1,000,000,007.

Definition

Class:
PlankTiling
Method:
sumup
Parameters:
int, int
Returns:
int
Method signature:
int sumup(int H, int W)
(be sure your method is public)

Constraints

  • H will be between 2 and 1000, inclusive.
  • W will be between 2 and 1000, inclusive.
  • W will be a multiple of H.

Examples

  1. 2
    4
    Returns: 11
    We are using 1x2 planks to tile a rectangle of width 4 and height 3. There are eleven different ways to do so:
  2. 4
    4
    Returns: 5
  3. 3
    9
    Returns: 121
  4. 29
    841
    Returns: 193514715
Back to all problems