10668  Expanding Rods
Moderator: Board moderators
Of course, the radius can be very long and we don't know an upper limit, therefore (I repeat myself) we do the following:htl wrote:Setting the range of y between 0 and 1.... But I thought that the radius could be very long as well as y. Could you give me more guidelines? I still work on finding the proper range that I could do bisection.
You probably overlooked/didn't understand the part "double y", meaning you should multiply y by 2 until the corresponding arc is short enough. In this way you find some upper bound (in logarithmic time) and then you can start searching in the range (0,y).misof wrote:Set y=1. While the arc is too long, double y. Then bsearch with initial bounds 0 and y.

 New poster
 Posts: 19
 Joined: Thu May 02, 2002 5:47 am
 Location: Zhongshan (Sun Yatsen) University
Could someone post some critical test cases pls ?
I tried almost everything, I mean binary search on the
center angle, on the radius, on the answer. I also tried
different end conditions  still WA.
I even rewrote my C++ program in Java and still WA.
The C++ program uses long double and the Java
program uses double as there is no long double
in Java.
The interesting fact is that my program only runs for 0.000
or 0.002 secs before getting WA. So it should be some
obvious problem which still I do not discover for the moment.
Any ideas are welcome Thanks in advance.
P.S.
I hate posting code so I am not doing it for the moment.
Although I am sure it is some very very small bug.
I tried almost everything, I mean binary search on the
center angle, on the radius, on the answer. I also tried
different end conditions  still WA.
I even rewrote my C++ program in Java and still WA.
The C++ program uses long double and the Java
program uses double as there is no long double
in Java.
The interesting fact is that my program only runs for 0.000
or 0.002 secs before getting WA. So it should be some
obvious problem which still I do not discover for the moment.
Any ideas are welcome Thanks in advance.
P.S.
I hate posting code so I am not doing it for the moment.
Although I am sure it is some very very small bug.
I got ACC, do not bother to answer me.
I just want to make a remark that could be of some
use in my opinion. My problem was the following one.
I was calling the function abs() with a long double argument.
My environment is VS .NET so I have as a builtin function
long double abs(long double)
Unfortunately when such code gets executed on the Judge's
Machine it actually produces a call to
int abs(int). In one of the emails from the Judge I suddenly
got a strange warning saying:
"03830241_24.c:34: warning: `long double' used
for argument 1 of `abs(int)' "
which made me suspect what I described above.
After writing on my own one new function
long double absLD(long double)
and after calling that function instead of
long double abs(long double)
I managed to get ACC immediately.
That was the reason I was getting all the time WA.
My code has just been behaving in a completely
different way on Judge's machine than on my machine.
Good luck to everyone !
I just want to make a remark that could be of some
use in my opinion. My problem was the following one.
I was calling the function abs() with a long double argument.
My environment is VS .NET so I have as a builtin function
long double abs(long double)
Unfortunately when such code gets executed on the Judge's
Machine it actually produces a call to
int abs(int). In one of the emails from the Judge I suddenly
got a strange warning saying:
"03830241_24.c:34: warning: `long double' used
for argument 1 of `abs(int)' "
which made me suspect what I described above.
After writing on my own one new function
long double absLD(long double)
and after calling that function instead of
long double abs(long double)
I managed to get ACC immediately.
That was the reason I was getting all the time WA.
My code has just been behaving in a completely
different way on Judge's machine than on my machine.
Good luck to everyone !
10668 why wronged
I got two equation.
L' = (1+nC)L = 2rθ  (1)
L = 2rsinθ  (2)
2rθ/(1+nC) = 2rsinθ
> θ = sinθ(1+nC)
I dirrerenciate this equation.
so 1 = cosθ(1+nC)
> θ = acos(1/(1+nC))
so I could know radious 'r' using equation (2) or (1)
so I could got a correct answer
BUT!!! may be this method is a wrong.
I can't have correct answer in example data case.
PLZ teach me why this method incorrect.
L' = (1+nC)L = 2rθ  (1)
L = 2rsinθ  (2)
2rθ/(1+nC) = 2rsinθ
> θ = sinθ(1+nC)
I dirrerenciate this equation.
so 1 = cosθ(1+nC)
> θ = acos(1/(1+nC))
so I could know radious 'r' using equation (2) or (1)
so I could got a correct answer
BUT!!! may be this method is a wrong.
I can't have correct answer in example data case.
PLZ teach me why this method incorrect.
Re: 10668 why wronged
Hi,
Of course this method doesn't work!
Consider θ = 2sinθ
Using your method, we get 1 = 2cosθ
=> θ = pi/3
but then 2sinθ = sqrt(3), i.e. your method fails...
And the reason why it fails is obvious. For a given t,
1. f(t) = g(t) does NOT imply that f'(t) = g'(t).
2. f'(t) = g'(t) does NOT imply that f(t) = g(t).
These can be seen easily from a graph.
Of course this method doesn't work!
Consider θ = 2sinθ
Using your method, we get 1 = 2cosθ
=> θ = pi/3
but then 2sinθ = sqrt(3), i.e. your method fails...
And the reason why it fails is obvious. For a given t,
1. f(t) = g(t) does NOT imply that f'(t) = g'(t).
2. f'(t) = g'(t) does NOT imply that f(t) = g(t).
These can be seen easily from a graph.
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
Re: 10668 why wronged
//Observer thanks
I got ACC but I have one more question.
I use bsearch to find out of theta.
But I got WA. because I use 'long double'
I don't know why 'long double' was wrong, and 'double' was correct.
I only change 'long double' of 'double'. and I got ACC.
Why?
I got ACC but I have one more question.
I use bsearch to find out of theta.
But I got WA. because I use 'long double'
I don't know why 'long double' was wrong, and 'double' was correct.
I only change 'long double' of 'double'. and I got ACC.
Why?

 Learning poster
 Posts: 60
 Joined: Sun Apr 16, 2006 7:59 pm
i'm getting wa..
i used bisection for the centered angle made by the chord...
someone pls tell what i'm missing...
thanks.
i used bisection for the centered angle made by the chord...
someone pls tell what i'm missing...
Code: Select all
#include <stdio.h>
#include <math.h>
#define err 1e10
//deleted after acc.
Last edited by ayeshapakhi on Fri Apr 06, 2007 4:45 pm, edited 1 time in total.

 Learning poster
 Posts: 60
 Joined: Sun Apr 16, 2006 7:59 pm
10668 wa
Pls someone provide me some testcases.
it seems tough to avoid precision errors...
i would be highly thankful..
it seems tough to avoid precision errors...
i would be highly thankful..