Page 2 of 3

### Hello.

Posted: Tue Jun 17, 2003 11:01 pm
It's me again.
I used that formula and got AC.
When you find a: a := int(exp((1/3)*ln(n))+0.0000000001);

That's all you need to do!

And you'll all get AC. I did it at C too and now I am on the 9-th place in statistics.

### Hello.

Posted: Tue Jun 17, 2003 11:02 pm
It's me again.
I used that formula and got AC.
When you find a: a := int(exp((1/3)*ln(n))+0.0000000001);

That's all you need to do!

And you'll all get AC. I did it at C too and now I am on 9-th place in statistics.

### Re: I don't like the judge!

Posted: Wed Jun 18, 2003 4:55 am
Finally, the Judge did something.

They added a special judging program for this qq.

Now there are no more WAs!!!!
(See ranklist: http://acm.uva.es/cgi-bin/OnlineJudge?ProblemStat:10509)

### 10509

Posted: Wed Jul 02, 2003 6:14 pm
Can someone help me with my code?? I'm really poor at the precision prob.
[c]
#include<stdio.h>
#include<math.h>
void main(void)
{
double n,a;
while(1)
{
scanf("%lf",&n);
if(n==0)
break;
a=ceil(pow(n,1.0/3.0))+0.0000000001;
if(a*a*a>n)
a--;
printf("%.4lf\n",(n+2*a*a*a)/3/a/a);
}
}
[/c]

Posted: Thu Jul 03, 2003 3:50 am
I'm afraid your code cannot even get the sample i/o correct......

That means your rounding function is incorrect:
[cpp] a=ceil(pow(n,1.0/3.0))+0.0000000001;[/cpp](Why +0.0000000001 ??)

And why do you declare a as double? After all a should always be an integer!!!

Change it and you'll get AC!

Posted: Thu Jul 03, 2003 9:20 am
I saw it in other articles that adding 0.0000000001 can improve the precision...

I modified the code and still got WA...
[c]
#include<stdio.h>
#include<math.h>
void main(void)
{
long a;
double n;
while(1)
{
scanf("%lf",&n);
if(n==0)
break;
a=pow(n,1.0/3.0);
printf("%.4lf\n",(n+2*a*a*a)/3/a/a);
}
}
[/c]

Posted: Thu Jul 03, 2003 10:36 am
OK. I think that that "+0.0000000001" should be put INSIDE the bracket...

[cpp]ceil(pow(n,1.0/3.0))+0.0000000001;[/cpp]you should have [cpp]ceil(pow(n,1.0/3.0)+0.0000000001);[/cpp]or simply this will do in this qq: [cpp]ceil(pow(n,1.0/3.0));[/cpp]
You should keep this:[cpp] if(a*a*a>n)
a--; [/cpp]

Posted: Thu Jul 03, 2003 6:55 pm
I got AC. And you're a great helper! Thanks!

### 10509 - speed??

Posted: Tue Oct 21, 2003 4:59 pm
Hi! I've got the usual solution in C++ for 10509, using pow() and a really short program but I get 0.600 seconds. I'm wondering, how the heck can people get 0.244 seconds in C++ for this program? I have tried precomputed look-up tables for my cubes, linear search through the table, binary search, etc. Nothing comes close.

Posted: Tue Oct 21, 2003 7:06 pm
You don't exactly need pow in this problem.

Posted: Wed Oct 22, 2003 1:16 am
Did you notice that I mentioned I tried look-up tables and binary searches and linear searches??? And they were slower??? Tell me, what is faster than pow()?

Posted: Wed Oct 22, 2003 8:41 am
Unless you're doing in the problem in a weird way, something like:

k * k * k should be enough..

Posted: Thu Oct 23, 2003 4:19 pm
Yes, one of my attempts was to use k*k*k and a linear search though all k (faster than binary search because k is small) to find the right k, and another attempt was to use a hard-coded lookup table of cubes plus linear search to find k, and again everything is way slower than my k = int(pow(n, 1.0/3.0) + 1e-12) solution. Is there any magic way to get the correct k?

### 10509 WA???HELP

Posted: Wed Jan 05, 2005 12:36 pm
HY Everybody
There Is Another Easy PROBLEM 10509 (R U KIDDING...).
BUT I GET WRONG ANSWER,BUT I DONT KNOW WHY
PLS.. CAN ANYONE GIVE ME SOME CRITICAL INPUT/OUTPT
THAT I CAN UNDERSTAND WHY WRONG ANSWER.....PLS......

Posted: Thu Jan 06, 2005 6:30 pm
Check your output for input 1.0000