#C289. Mandelbrot Set Generator

    ID: 46255 Type: Default 1000ms 256MiB

Mandelbrot Set Generator

Mandelbrot Set Generator

This problem requires you to generate a 2D representation of the Mandelbrot set. For each pixel in a grid with a given width and height, map the pixel coordinates to the complex plane using the following linear transformation:

\[ c = -2 + \frac{3 \times col}{width} + \left(-1.5 + \frac{3 \times row}{height}\right)i \]

Then, starting with \(z_0 = 0\), compute the iterations according to the formula \[ z_{n+1} = z_n^2 + c \] until \(|z| > 2\) or a maximum number of iterations (max_iter) is reached. If a point does not escape (i.e. it never satisfies \(|z| > 2\)) after max_iter iterations, output 0 for that point. Otherwise, output the iteration count at which the point escaped.

The final output should be the grid of iteration counts. Note that all mathematical formulas are expressed in LaTeX format.

inputFormat

The input consists of a single line containing three space-separated integers:

  • width: the number of columns (the width of the output grid).
  • height: the number of rows (the height of the output grid).
  • max_iter: the maximum number of iterations in the Mandelbrot computation.

outputFormat

Output the Mandelbrot set as a grid with height lines, each containing width space-separated integers. Each integer represents the iteration count at which the corresponding point escaped, or 0 if it did not escape within max_iter iterations.

## sample
3 3 100
1 2 2

1 0 0 1 0 0

</p>