标签:order its logs fabs ase where esc walk least
不想好好写这个了。。。
Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5462 Accepted Submission(s): 1707
#include<bits/stdc++.h> using namespace std; #define N 50500 struct node{ double p; double w; }a[N]; int n; double sum(double mid){ double sum=0.0; for(int i=0;i<n;i++){ double s=fabs(a[i].p-mid); sum+=s*s*s*a[i].w; } return sum; } double sanfen(double l,double r){ double mid,midd,ans1,ans2,left,right; left=l;right=r; while(left+0.000000001<right){ mid=(left+right)/2.0; midd=(mid+right)/2.0; ans1=sum(mid); ans2=sum(midd); if(ans1<ans2)right=midd; else left=mid; } return left; } int main(){ int t,num; double left,right,ans,m; num=0; while(~scanf("%d",&t)){ while(t--){ num++; left=1e5;right=1e-5; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%lf%lf",&a[i].p,&a[i].w); left=min(left,a[i].p); right=max(right,a[i].p); } m=sanfen(left,right); ans=sum(m); printf("Case #%d: %.0lf\n",num,ans); } } return 0; }
我好饿。。。咕~~(╯﹏╰)b
没力气写了。(*/ω\*)
。。。
标签:order its logs fabs ase where esc walk least
原文地址:http://www.cnblogs.com/ZERO-/p/6724892.html