/*
 * 三分查找
 */
#include<cstdio>
#include<cmath>
#define eps 1e-6

//typedef __int64 LL;

int n;
double x[50005], w[50005];

double func(double y){
    double res=0;
    for(int i=0;i<n;i++){
        double a=y-x[i];
        a=a<0?-a:a;
        res+=a*a*a*w[i];
    }
    return res;
}

int main(){
    int T;
    scanf("%d",&T);
    for(int t=1;t<=T;t++){
        scanf("%d",&n);
        for(int i=0;i<n;i++){
            scanf("%lf%lf",&x[i],&w[i]);
        }
        double l=x[0],r=x[n-1],mid,mmid;
        while(r-l>eps){
            mid=(l+r)/2.0;
            mmid=(mid+r)/2.0;
            if(func(mid)-func(mmid)>eps){
                l=mid;
            }
            else{
                r=mmid;
            }
        }

printf("Case #%d: %lld\n",t,(long long)(func(r)+0.5));

//hdu要用int64

}
}

最新文章

  1. phpcms中的RBAC权限系统
  2. nginx 基本操作
  3. java UDP
  4. AFNetworking 基本使用
  5. CLGeocoder "Lost connection to geod" #error# when use geocodeAddressString:completionHandler
  6. Maven学习总结(二)——Maven项目构建过程练习
  7. AC自动机 - 多模式串的匹配运用 --- HDU 3065
  8. php向队列服务里插入一条insert sql例如
  9. io资料
  10. mysql---整体备份和增量备份
  11. ORACLE模拟临时文件、日志成员、口令文件丢失情况与恢复【weber出品】
  12. 中小企业为什么要上HR系统
  13. OpenGL——OpenCV与SOIL读取图片进行纹理贴图
  14. 2019-4-26 css学习笔记
  15. SpringMVC @SessionAttributes 使用详解以及源码分析
  16. (笔记)Ubuntu下安装arm-linux-gcc-4.4.3.tar.gz (交叉编译环境)
  17. 地址解析协议ARP(Address Resolution Protocol)
  18. global statement
  19. IStat Menus 5.02 5.03 的注册码
  20. 3.10 Templates -- Development Helpers

热门文章

  1. HNOI2018思记
  2. 2-sat——hdu3062
  3. linux和window环境下安装ruby和sass
  4. c语言学习笔记 - 指针和字符串
  5. 【breathandlife】气势磅礴、比较好听的旋律有哪些?
  6. IDEA中Git的使用(多人合作)
  7. Netty设置高低水位
  8. 04_Spring AOP两种代理方法
  9. Redis List类型学习
  10. C++ 赋值函数为什么返回reference to *this?