Page 1 of 1

### 918 - ASCII Mandelbrot

Posted: Fri Oct 06, 2006 1:46 pm
I don't know what's wrong with my code,
seems it's bigger than a precision problem
any sugestions?

Code: Select all

``````//ACC
``````

Posted: Fri Oct 06, 2006 9:54 pm

Code: Select all

``````int test(double x,double y)
{
double zr=0,zi=0;
int k=0;
double d = 0;
while (d<=2.00000001 && k<=12)
{
zr = zr*zr - zi*zi;
// You have changed zr
zi = 2*zr*zi;
// You are using the wrong zr (updated one)
zr += x;
zi += y;
k++;
d= sqrt(zr*zr + zi*zi);
}
return k;
} ``````
Hope it helps.

Posted: Sat Oct 07, 2006 4:06 pm
oops
thanx!

Posted: Sun Oct 15, 2006 5:48 pm
Although I get AC, I am still confused.

For first input:
-1.2 1.2 0.1 -2 1 0.05

So in the graph,
I is { -1.2, -1.1, -1.0, ..., 1.1, 1.2 } 25 rows
R is { -2, -1.95, -1.9, ..., 0.9, 0.95, 1.00} 61 columns
But the sample output has 25 rows and 60 columns only.

I try to submit a program that will generate 61 columns, and I get WA.
Here is the loop part in my program:

Code: Select all

``````row = floor((MaxI - MinI) / PrecI + 1e-12) + 1;
col = floor((MaxR - MinR) / PrecR + 1e-12) + 1;
for (i = 0; i < row; i++) {
for (j = 0; j < col; j++) {
}
}
``````
Then I change my program to

Code: Select all

``````for (I = MinI; I <= MaxI; I += PrecI)
for (R = MinR; R <= MaxR; R += PrecR)
{
.......
}
``````
Now my program generate the same output as sample output and get AC.

Can anyone tell me what's wrong? It is my silly mistake or there is precision error on the judge data???? Thanks

Posted: Sun Oct 15, 2006 6:30 pm
The judge data is wrong. I have mailed about this problem in the bugs and suggestions forum. But they haven't replied yet.

### Caution on Long Doubles

Posted: Wed Oct 18, 2006 3:17 am
I also used the loop

Code: Select all

``````for (im = min_i; im <= max_i; im += prec_i) {
for (re = min_r; re <= max_r; re += prec_r) {
...
}
}
``````
where im & re were of both of type 'long double' and recieved WA. I changed them to simply 'double' and got AC.

Posted: Wed Apr 25, 2007 1:22 pm
Sorry, one silly question:
For the iteration,
Z = Z^2 + C

what is C?
I have read through the question for several times
but still can't figure out what C is...

Posted: Wed Apr 25, 2007 8:15 pm
The test is based on the equation Z = Z^2 + C. C represents a constant number, meaning that it does not change during the testing process. C is the number we are testing, the point on the complex plane that will be plotted when testing is complete.
Hope it helps.

Posted: Thu Apr 26, 2007 3:08 pm

Yet.. I'm confused by the dimension...
There should be sth wrong in the for loop...
making me receiving WA..

Code: Select all

``ACed[code]``

Posted: Sat Apr 28, 2007 10:42 pm
Your code doesn't pass the first sample. Check the first sample (13th line).

Hope it helps.

Posted: Sun Jun 17, 2007 7:09 pm
Jan wrote:Your code doesn't pass the first sample. Check the first sample (13th line).

Hope it helps.
At the first time when you gave me your hint, I can't figure out why my code gave wrong output.
Now, I recognized what's wrong in my code...!

ROUND-OFF ERROR!!

Thx again, Jan

### Re: 918 - ASCII Mandelbrot

Posted: Mon Mar 13, 2017 10:24 am
The description of problem is not so clear.
Z = Z * Z + C means:
Given a complex number C = 1 + i
iteration 1: Z = 0 + C = 1 + i, d = sqrt(1 + 1) = sqrt(2);
iteration 2: Z = (1 + i) * (1 + i) + (1 + i) = 1 + 3i, d = sqrt(1 + 9) = sqrt(10);
...