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

试了很多组数据了,都没问题,为什么一提交就tle呢? 麻烦大家帮我看看,莫非是二分的不对?

Posted by radish at 2005-09-16 08:26:27 on Problem 2601
#include<iostream.h>
int main()
{
    float *a,*c,csum,m,j,k;
    int n,i;
    cin>>n;
    a=new float[n+2],c=new float[n+1];
    cin>>a[0]>>a[n+1];
    for(csum=0,i=1;i<=n;i++){cin>>c[i];csum+=c[i];}
    if(n==1)a[1]=(a[0]+a[2])/2-c[1];
    else
    for(m=a[0]+a[n+1]-2*csum,j=-1000,k=1000;a[1]+a[n]-m>0.001||a[1]+a[n]-m<-0.001;)
    {
        a[1]=(j+k)/2;
        for(i=2;i<=n;i++)a[i]=2*(a[i-1]+c[i-1])-a[i-2];
        if(a[1]+a[n]<m)j=a[1];
        else k=a[1];
    }
    return 1;
}

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