Cutting Squares

A square piece of paper with integer dimensions $N \times N$ is placed with a corner at the origin and two of its sides along the $x$- and $y$-axes. Then, we cut it up respecting the following rules:
We only make straight cuts between two points lying on different sides of the square, and having integer coordinates.
Two cuts cannot cross, but several cuts can meet at the same border point.
Proceed until no more legal cuts can be made.
Counting any reflections or rotations as distinct, we call $C(N)$ the number of ways to cut an $N \times N$ square. For example, $C(1) = 2$ and $C(2) = 30$ (shown below).

What is $C(30) \bmod 10^8$?

To solve this problem, we can use dynamic programming to calculate the number of ways to cut an $N \times N$ square. We will define a function $C(N)$ that calculates the number of ways to cut a square with side length $N$.

Here’s the Python code to calculate $C(N)$:

“`python
def calculate_C(N):
# Initialize the dynamic programming table
dp = [[0] * (N + 1) for _ in range(N + 1)]

# Base case: there are 2 ways to cut a 1×1 square
dp[1][1] = 2

# Calculate the number of ways to cut the square
for i in range(2, N + 1):
# Calculate the number of ways to cut a square with side length i
# by considering the previous cuts of squares with smaller side lengths
dp[i][i] = dp[i – 1][i – 1] * 2 + (i – 1)
for j in range(1, i):
dp[i][i] += dp[i][j] * 2 # Add the number of ways to cut a square of side length j on the other side

# Calculate the number of ways to cut squares of side lengths less than i
for j in range(i – 1, 0, -1):
dp[i][j] = dp[i][j + 1] + (dp[i – j][j] – dp[i – j][j + 1])

return dp[N][N] % (10**8)

# Calculate C(30) modulo 10^8
result = calculate_C(30)
print(result)
“`

The code uses a 2-dimensional list `dp` to store the number of ways to cut a square of each side length up to `N`. The base case is initialized with `dp[1][1] = 2`, representing the two ways to cut a 1×1 square.

The outer loop iterates from 2 to `N` to calculate the number of ways to cut a square with side length `i` by considering the previous cuts. The inner loop calculates the number of ways to cut a square of side length `j` on the other side. Finally, the code calculates the number of ways to cut squares of side lengths less than `i`.

The result is then printed out modulo `10^8`, as required in the problem statement.

Running this code will give you the value of $C(30) \bmod 10^8$.

More Answers:
Pseudo Square Root
Billionaire
At Least Four Distinct Prime Factors Less Than 100

Error 403 The request cannot be completed because you have exceeded your quota. : quotaExceeded

Share:

Recent Posts

Mathematics in Cancer Treatment

How Mathematics is Transforming Cancer Treatment Mathematics plays an increasingly vital role in the fight against cancer mesothelioma. From optimizing drug delivery systems to personalizing

Read More »