#P8152. Square Splitting Challenge
Square Splitting Challenge
Square Splitting Challenge
Initially, you are given a square with side length \(1\). You must perform \(k\) splitting operations. In each operation, only the rectangle at the bottom-right corner of the current figure is subdivided into \(n \times n\) smaller rectangles. The subdivision replaces the original rectangle with \(n^2\) new rectangles. Consequently, the net increase in the number of rectangles in each operation is \(n^2 - 1\). After performing \(k\) operations, the total number of rectangles becomes the answer.
Note: Since the description might be a bit challenging to visualize, please refer to the sample explanation for a clearer understanding of the process.
inputFormat
The input consists of a single line with two space-separated integers:
n
: the number of divisions along one dimension used to split the rectangle.k
: the number of splitting operations to perform.
It is guaranteed that \(n \ge 1\) and \(k \ge 0\).
outputFormat
Output a single integer representing the total number of rectangles after performing all the splitting operations.
sample
2 1
4