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

不是WA就是tle,有什么好方法吗?(附程序)

Posted by TN at 2005-01-24 13:02:36 on Problem 1905
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
double l,n,c,l1,hi,lo,pi,mid,f;
int main(void){

    while(true){
        scanf("%lf %lf %lf",&l,&n,&c);
        if(l<0 || n<0 ||c<0)break;
        l1=l+n*c*l;
        pi=3.1415926;mid=0;
        hi=pi/2;lo=0;mid=(hi+lo)/2;
        f=mid*l-sin(mid)*l1;
        while (abs(f)>1e-12)
        {         
            if (f>0) hi=mid; else lo=mid;
            mid=(hi+lo)/2;
            f=mid*l-sin(mid)*l1;
        }                
        printf("%.3lf\n",l1/mid/2*(1-cos(mid)));
    }
    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