Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
二分做这题TLE有毒!改了两个地方就AC,一个是 把排序的定义方式cmp写成结构体里对<的重载 bool cmp(node a,node b) { return a.b>=b.b; } 改成: struct node { double b;int t; bool operator<(const struct node&a)const//重载运算符 { return b>a.b; } }a[100000+10]; 还有吧二分精度写成1e-6次方,开始我写的都是for(int i=0;i<100;i++){} for(int i=0;i<100;i++){ double mid=(l+r)*0.5; if(check(mid)) l=mid; else r=mid; } 改成: while(r-l>=1e-6){ double mid=(l+r)*0.5; if(check(mid)) l=mid; else r=mid; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator