Connection Status:
Competition Arena > FloorTiling
TCO05 Sponsor 2 · 2005-08-16 · by lars2520 · Math
Class Name: FloorTiling
Return Type: int
Method Name: tile
Arg Types: (int, int, int, int)
Problem Statement

Problem Statement

You are tiling a floor that is width by height units. You are using strips of tile that are size by 1 units. The long side of the tiles should run along the side of the floor that is width units long. See the diagram for more details on exactly how the tiles should be placed.

Note how each row is offset by offset units from the one below it. (When thinking of how to offset the rows, imagine infinite horizontal strips of tiles.) Also, notice that the bottom row is touching the side. As the diagram illustrates, you will not be able to tile the whole floor with pieces that are size by 1. You should return the area of the region that will not be covered when tiling according to the strategy shown in the image.

Constraints

  • offset will be between 0 and size-1, inclusive.
  • size will be between 2 and floor(width/2), inclusive.
  • width and height will each be between 4 and 50, inclusive.
Examples
0)
3
2
7
8
Returns: 17

The example in the diagram above.

1)
5
1
10
8
Returns: 30
2)
2
1
50
50
Returns: 50
3)
2
0
4
4
Returns: 0
4)
24
23
50
50
Returns: 1132

Submissions are judged against all 41 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class FloorTiling with a public method int tile(int size, int offset, int width, int height) · 41 test cases · 2 s / 256 MB per case

Submitting as anonymous