Cover a square with rectangles

Suppose that you have an infinite suply of m × 2m rectangles for every
natural m ≥ 1. You have to exactly cover an ℓ × ℓ square (you can choose
ℓ ) by placing n of those rectangles horizontally or vertically. For
instance, these are some ways for n = 2, n = 5 and n = 6:

(10,6)

(0,0)(0,1)(2,1)(2,0) (0,1)(0,2)(2,2)(2,1)

(4,0)(4,4)(6,4)(6,0) (6,0)(6,2)(7,2)(7,0) (7,0)(7,2)(8,2)(8,0)
(6,3)(6,4)(8,4)(8,3) (6,2)(6,3)(8,3)(8,2)

(10,0)(10,4)(12,4)(12,0) (10,4)(10,6)(14,6)(14,4)
(14,2)(14,6)(16,6)(16,2) (12,0)(12,2)(16,2)(16,0)
(12,2)(12,3)(14,3)(14,2) (12,3)(12,4)(14,4)(14,3)

There are only a few n for which it is impossible to cover a square with
n such rectangles. In particular, it is always possible when n%3 = 2.
Can you prove it?

Input

Input consists of several n such that n ≡ 2 (mod  3). Assume 2 ≤ n ≤ 62.

Output

For every n, first print a line with an ℓ between 2 and 30. Afterwards,
print ℓ lines with ℓ characters each. Use different digits, lowercase
letters and uppercase letters to indicate each rentangle. Since there
are multiple possible solutions, print any one.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T11:38:38.744Z

© Jutge.org, 2006–2026.
https://jutge.org
