Statistics

Problem Statement for "FloorTiling"

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.

Definition

Class:
FloorTiling
Method:
tile
Parameters:
int, int, int, int
Returns:
int
Method signature:
int tile(int size, int offset, int width, int height)
(be sure your method is public)

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

  1. 3

    2

    7

    8

    Returns: 17

    The example in the diagram above.

  2. 5

    1

    10

    8

    Returns: 30

  3. 2

    1

    50

    50

    Returns: 50

  4. 2

    0

    4

    4

    Returns: 0

  5. 24

    23

    50

    50

    Returns: 1132

  6. 4

    1

    11

    34

    Returns: 102

  7. 5

    0

    10

    15

    Returns: 0

  8. 14

    1

    41

    45

    Returns: 585

  9. 9

    8

    23

    41

    Returns: 340

  10. 4

    2

    8

    28

    Returns: 56

  11. 5

    4

    28

    12

    Returns: 51

  12. 3

    2

    42

    48

    Returns: 96

  13. 13

    2

    46

    36

    Returns: 421

  14. 4

    0

    48

    9

    Returns: 0

  15. 8

    3

    43

    16

    Returns: 112

  16. 4

    2

    9

    4

    Returns: 12

  17. 19

    10

    50

    14

    Returns: 244

  18. 4

    0

    41

    9

    Returns: 9

  19. 6

    3

    17

    13

    Returns: 65

  20. 9

    1

    31

    45

    Returns: 360

  21. 5

    4

    49

    34

    Returns: 136

  22. 13

    0

    38

    9

    Returns: 108

  23. 2

    1

    39

    24

    Returns: 24

  24. 7

    6

    41

    5

    Returns: 30

  25. 7

    5

    39

    46

    Returns: 275

  26. 2

    0

    24

    29

    Returns: 0

  27. 5

    1

    10

    20

    Returns: 80

  28. 2

    1

    6

    4

    Returns: 4

  29. 10

    5

    50

    50

    Returns: 250

  30. 5

    3

    13

    50

    Returns: 200

  31. 5

    1

    10

    8

    Returns: 30

  32. 3

    2

    7

    4

    Returns: 7

  33. 4

    0

    9

    4

    Returns: 4

  34. 2

    0

    6

    5

    Returns: 0

  35. 6

    5

    13

    4

    Returns: 22

  36. 24

    23

    49

    4

    Returns: 76

  37. 4

    3

    10

    49

    Returns: 146

  38. 4

    2

    8

    4

    Returns: 8

  39. 4

    2

    10

    4

    Returns: 8

  40. 23

    17

    50

    50

    Returns: 1097

  41. 2

    1

    50

    5

    Returns: 4


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: