Page 3 of 3

Posted: Fri Apr 06, 2007 1:15 pm
by Jan
First search your problem. If you find any thread then use it. If no thread is found then and only then you are allowed to open a new thread.

However, check the thread.

Posted: Fri Apr 06, 2007 1:43 pm
by ayeshapakhi
Thanks a lot for help.
i've seen that thread before posting here. There's no testcases.
I can't find any logical error in my code (used bisection and it seems all of my i/o 's are ok) and finally i posted my code in another thread but there's no reply...
so......

thanks.

Posted: Fri Apr 06, 2007 1:56 pm
by Jan
Replace

Code: Select all

#define err 1e-10
with

Code: Select all

#define err 1e-13
Hope you get accepted.

Posted: Fri Apr 06, 2007 2:00 pm
by Jan
You have to be patient. If you find no reply (for a long time) then you can post in that thread again, like "Can anyone help?". Actually when we log in, we check the new posts. Thats why we can check your problem again.

Posted: Fri Apr 06, 2007 4:50 pm
by ayeshapakhi
Strange!!
Really it got acc!.........
Infinite thanks for u.

Thanks again.

Posted: Fri Apr 06, 2007 4:54 pm
by ayeshapakhi
Sorry for inconvenience....
Thanks a lot for help.......

Posted: Tue Feb 05, 2008 8:20 am
by gba356
I've used 1e-15 as my epislon, but the online judge system keeps give me constant WA. Can somebody check my code? I choose Bisection as my algo.

Code: Select all

#include<iostream>
#include<cmath>
#define e ( 1e-15 )
using namespace std;
    double L,n,C,S,S2,theta,r;
    
inline double ABS( double x )
{
    return( x>0 ? x : -x );
}    

inline double f( double x )
{
    return(   S2 * sin( x/2 ) - L * x   );
}

double Bisection( double L,double R )
{
    double M;
    double fL = f(L) ,fR = f(R), fM;
    
    if( ABS( fR )<e )return R;
    if( ABS( fL )<e )return L;
    
    while( R-L>e )
    {
        M = ( L+R ) / 2;
        fM = f(M);
        if( ABS( fM )<e )
            return M;
        else if( fL*fM<0 )
            R = M, fR = fM;
        else
            L = M, fL = fM;
    }
    return L;
}

int main()
{
    cout.setf( ios::fixed );
    cout.precision( 3 );
    const double PI = acos( -1.000 );
    while( cin>>L>>n>>C,(  L>=0 || n>=0 || C>=0  ) )
    {
        if( C==0 || n==0 )
        {
            cout<<"0.000"<<endl;
            continue;
        }
        S = ( 1.000 + n*C ) * L;
        S2 = 2.000*S;
        theta = Bisection( e,PI-e );
        r = S/theta;
        cout<<(   r - r*cos( theta/2.000 )   )<<endl;
    }
}


Re: 10668 - Expanding Rods

Posted: Thu Jan 01, 2009 2:33 am
by tryit1
i used long double , and EPS as 1e-13

Code: Select all

1000 100 0.0001
15000 10 0.00006
15000 20 0.00006
15000 20 0.00089
10 1 0.001
10 0 0.001
1 5 0.2333
5 1 0.2333
5300 100 0.5323
15 415 0.0044
15 15 3.333
-1 -1 -1

Code: Select all

61.329
225.020
318.255
1228.775
0.194
0.000
0.000
1.529
0.000
0.000
0.000

Re: 10668 - Expanding Rods

Posted: Fri Jan 27, 2012 5:35 pm
by plamplam
I used binary search on theta, after getting a couple of wrong answers, when I handled cases like n = 0, l = 0 or c = 0, I got Accepted. Here are some cases:

Code: Select all

1000 100 0.0001
0 100 0.0001
1000 0 0.0001
1000 100 0
15000 10 0.00006
10 0 0.001
-112 -1121212 -1324

Code: Select all

61.329
0.000
0.000
0.000
225.020
0.000