Using Up to One Million Tiles How Many Different "Hollow" Square Laminae Can Be Formed?
A hollow square lamina is formed by removing a smaller concentric square hole from a larger square. Using up to N = 10^6 unit-square tiles, how many distinct hollow square laminae can be formed?
Problem Statement
This archive keeps the full statement, math, and original media on the page.
We shall define a square lamina to be a square outline with a square "hole" so that the shape possesses vertical and horizontal symmetry. For example, using exactly thirty-two square tiles we can form two different square laminae:

With one-hundred tiles, and not necessarily using all of the tiles at one time, it is possible to form forty-one different square laminae.
Using up to one million tiles how many different square laminae can be formed?
Problem 173: Using Up to One Million Tiles How Many Different “Hollow” Square Laminae Can Be Formed?
Mathematical Development
Definition 1. A hollow square lamina is parameterized by a pair of positive integers with and , where is the outer side length, is the inner side length, and the congruence condition ensures the hole is centered (uniform border width ).
Theorem 1 (Tile count). A hollow square lamina uses exactly tiles.
Proof. The lamina occupies unit cells minus the cells removed for the interior hole.
Lemma 1 (Factored form). Setting (the border width), the tile count becomes . For fixed border width , the outer side ranges over integers (so that ), subject to .
Proof. We have . With , we obtain , so . The constraint gives , i.e., .
Lemma 2 (Range of the outer side). The minimum tile count for a given outer side is achieved at (border width ), giving . Hence a necessary condition for a lamina with outer side to exist is .
Proof. The largest allowable inner side is , which minimizes . Computing: iff .
Theorem 2 (Counting formula). For each outer side with , the number of valid inner sides is
where and is the smallest positive integer satisfying and . If no such exists (i.e., ), then .
Proof. The valid values of form an arithmetic progression with common difference 2. The number of terms in such a progression with first term and last term is .
Corollary 1. The total number of laminae is .
Editorial
Count distinct hollow square laminae using at most N = 10^6 tiles. Lamina (a, b): outer side a, inner side b, same parity, tiles = a^2 - b^2. We else.
Pseudocode
N = 10^6
total = 0
for a = 3, 4, 5, ...:
If 4*(a - 1) > N then stop this loop
b_max = a - 2
lo = a*a - N
If lo <= 1 then
b_min = (2 if a is even else 1)
else:
b_min = ceil(sqrt(lo))
if b_min % 2 != a % 2: b_min += 1
If b_min <= b_max then
total += (b_max - b_min) // 2 + 1
Return total
Complexity Analysis
- Time: The outer loop runs for , giving iterations, each performing arithmetic (one integer square root and constant-many comparisons).
- Space: .
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
#include <bits/stdc++.h>
using namespace std;
/*
* Problem 173: Count hollow square laminae with at most N = 10^6 tiles.
* Lamina (a, b): outer side a, inner side b, same parity, tiles = a^2 - b^2.
* For each a >= 3, count valid inner sides b.
*/
int main() {
long long N = 1000000;
long long total = 0;
for (long long a = 3; 4 * (a - 1) <= N; a++) {
long long b_max = a - 2;
long long lo = a * a - N;
long long b_min;
if (lo <= 1) {
b_min = (a % 2 == 0) ? 2 : 1;
} else {
b_min = (long long)ceil(sqrt((double)lo));
while (b_min * b_min < lo) b_min++;
if (b_min % 2 != a % 2) b_min++;
}
if (b_min > b_max) continue;
total += (b_max - b_min) / 2 + 1;
}
cout << total << endl;
return 0;
}
"""
Problem 173: Hollow Square Laminae
Count distinct hollow square laminae using at most N = 10^6 tiles.
Lamina (a, b): outer side a, inner side b, same parity, tiles = a^2 - b^2.
"""
import math
def solve():
N = 1_000_000
total = 0
a = 3
while 4 * (a - 1) <= N:
b_max = a - 2
lo = a * a - N
if lo <= 1:
b_min = 2 if a % 2 == 0 else 1
else:
b_min = math.isqrt(lo - 1) + 1
while b_min * b_min < lo:
b_min += 1
if b_min % 2 != a % 2:
b_min += 1
if b_min <= b_max:
total += (b_max - b_min) // 2 + 1
a += 1
print(total)
if __name__ == "__main__":
solve()