1.

package asciiMandelbrot;

/**
* FWP, Ausgew√¤hlte Probleme aus dem ACM Programming Contest, WS10/11
* Problem: 918 Ascii Mandelbrot
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&page=show_problem&problem=859
*
* @author Patrick Bédat
* @author Christoph Göttschkes
* @author Philippe Brousse
* @version 1.0, 14.11.2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.100
*/
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.*;

class Main
{

static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

public static void main(String[] agrs) throws IOException
{
int testCases = Integer.parseInt(reader.readLine());

for (int curCase = 0; curCase < testCases; curCase++)
{
String line = reader.readLine();
StringTokenizer tokenizer = new StringTokenizer(line);
char[] chars = tokenizer.nextToken().substring(1, 13).toCharArray();

double minImaginary = Double.parseDouble(tokenizer.nextToken());
double maxImaginary = Double.parseDouble(tokenizer.nextToken());
double precImaginary = Double.parseDouble(tokenizer.nextToken());
double minReal = Double.parseDouble(tokenizer.nextToken());
double maxReal = Double.parseDouble(tokenizer.nextToken());
double precReal = Double.parseDouble(tokenizer.nextToken());

StringBuilder builder = new StringBuilder();
for (double img = minImaginary; img <= maxImaginary + 0.00000001; img += precImaginary)
{
for (double real = minReal; real <= maxReal + 0.00000001; real += precReal)
{

int c = test(img, real, precImaginary, precReal);
if (c >= 12)
builder.append(" ");
else
builder.append(chars[c]);
}
builder.append("\n");
}
System.out.print(builder);
if (curCase < testCases - 1)
System.out.println();
}
}

static int test(double img, double real, double precImg, double precReal)
{
double magnitude = img * img + real * real;
double zImg = img;
double zReal = real;

int c = 0;

while (magnitude <= 4.000000001 + Double.MIN_VALUE && c < 20)
{
double temp = zImg;
zImg = 2 * zImg * zReal + img;
zReal = ((zReal * zReal) - (temp * temp)) + real;
magnitude = zImg * zImg + zReal * zReal;
c++;
}
return c;
}
}