10509  R U Kidding Mr. Feynman?
Moderator: Board moderators

 Experienced poster
 Posts: 131
 Joined: Thu Apr 17, 2003 8:39 am
 Location: Baku, Azerbaijan
Hello.
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 9th place in statistics.
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 9th place in statistics.
_____________
NO sigNature
NO sigNature

 Experienced poster
 Posts: 131
 Joined: Thu Apr 17, 2003 8:39 am
 Location: Baku, Azerbaijan
Hello.
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 9th place in statistics.
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 9th place in statistics.
_____________
NO sigNature
NO sigNature
Re: I don't like the judge!
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/cgibin/OnlineJudge?ProblemStat:10509)
They added a special judging program for this qq.
Now there are no more WAs!!!!
(See ranklist: http://acm.uva.es/cgibin/OnlineJudge?ProblemStat:10509)
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00  16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00  16:00 (UTC)
URL: http://uva.onlinejudge.org
10509
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]
[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]
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!
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!
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00  16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00  16:00 (UTC)
URL: http://uva.onlinejudge.org
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]
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]
OK. I think that that "+0.0000000001" should be put INSIDE the bracket...
That is, instead of
[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]
That is, instead of
[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]
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00  16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00  16:00 (UTC)
URL: http://uva.onlinejudge.org
10509  speed??
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 lookup tables for my cubes, linear search through the table, binary search, etc. Nothing comes close.
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 hardcoded 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) + 1e12) solution. Is there any magic way to get the correct k?
10509 WA???HELP
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......
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......