Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

谢谢styc,凭感觉写了牛顿法,感觉自己太差了,用什么方法都WA,郁闷。

Posted by sunmoonstar_love at 2005-07-06 01:39:30 on Problem 1905
In Reply To:用二分法做的,但总是WA,兄弟们帮看看 Posted by:sunmoonstar_love at 2005-07-05 23:21:38
    x为初始值,y为函数目标值
   fx是函数值,ffx是一阶导


double Newton(double x,double y)
{
double xn1, xn,fx,ffx;
xn1 = x;
do{
    xn = xn1;
    fx = sin(xn)/xn - y;
    ffx = (xn*cos(xn)-sin(xn))/(xn*xn);
    xn1 = xn - (fx/ffx);
}while(abs(fx) > 1.0e-12);
//printf("%.6lf    %.6lf\n",sin(xn)/xn, y);
return xn1;
}
int main()
{
    double l,n,c,l1,angle,tmp,pi;
    while(scanf("%lf%lf%lf",&l,&n,&c)&& (l!=-1))
    {
        if(n==0.00||l<0.001) 
        { 
            printf("%.3lf\n",0); 
            continue; 
        }  
        l1 = l*(1+n*c);
        pi = 3.1415926535897932384626433832795;
        angle = Newton(pi / 2,1/(1+n*c));
        printf("%.3lf\n",l1/angle/2*(1-cos(angle)));    
    }    
    return 0;
} 

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator