#P7695. Counting Distinct Points in Mirko's Algorithm
Counting Distinct Points in Mirko's Algorithm
Counting Distinct Points in Mirko's Algorithm
Mirko starts with 4 points forming a perfect square. He applies the following steps on each square:
- On each edge of the square, he adds a new point at the midpoint. The height at this point is the average of the heights of the two endpoints of that edge.
- At the center of the square, he adds another point. The height here is the average of the heights of all 4 corner points plus a small random value.
After completing these operations on one square, he ends up with 4 new squares. He repeats this process n times. Note that some points lie on the boundaries of multiple squares; however, once a point is stored in memory it is stored only once permanently.
Your task is to compute the total number of distinct points stored in memory after n iterations. It can be shown that the total number of points is given by the formula:
\( (2^n + 1)^2 \)
inputFormat
The input consists of a single non-negative integer n
indicating the number of iterations.
outputFormat
Output a single integer representing the total number of distinct points stored in memory, which is given by \( (2^n + 1)^2 \).
sample
0
4