只能说感觉是三分吧,因为两端值肯定是最大的,而中间肯定存在一点使之最小,呃,,,,猜 的。。。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define LL __int64
using namespace std;
const int N=50050; double point[N];
double weight[N];
int n; double cal(double x){
double ans=0,t;
for(int i=1;i<=n;i++){
t=fabs(x-point[i]);
ans+=(t*t*t*weight[i]);
}
return ans;
} int main(){
int T,t=0;
scanf("%d",&T);
while(++t<=T){
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%lf%lf",&point[i],&weight[i]);
double l=point[1],r=point[n],m,mm;
while(l+(1e-8)<=r){
m=l+(r-l)/3;
mm=r-(r-l)/3;
if(cal(m)>cal(mm))
l=m;
else r=mm;
}
double ans=cal(l);
printf("Case #%d: %.0lf\n",t,ans);
}
return 0;
}

  

HDU 4355的更多相关文章

  1. codeforces 782B The Meeting Place Cannot Be Changed+hdu 4355+hdu 2438 (三分)

                                                                   B. The Meeting Place Cannot Be Change ...

  2. hdu 4355 Party All the Time(三分搜索)

    Problem Description In the Dark forest, there is a Fairy kingdom where all the spirits will go toget ...

  3. HDU 4355 Party All the Time (三分求极值)

    题意:给定x轴上有n个点,每一个点都有一个权值,让在x轴上选一个点,求出各点到这个点的距离的三次方乘以权值最小. 析:首先一开始我根本不会三分,也并没有看出来这是一个三分的题目的,学长说这是一个三分的 ...

  4. HDU 4355.Party All the Time-三分

    Party All the Time Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  5. HDU 4355——Party All the Time——————【三分求最小和】

    Party All the Time Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  6. HDU 4355 Party All the Time(三分|二分)

    题意:n个人,都要去參加活动,每一个人都有所在位置xi和Wi,每一个人没走S km,就会产生S^3*Wi的"不舒适度",求在何位置举办活动才干使全部人的"不舒适度&quo ...

  7. HDU 4355:Party All the Time(三分模板)

    Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s) ...

  8. hdu4355 三分

    F - 三分 Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:32768KB     64bit I ...

  9. hdu 1869 (Floyd)

    http://acm.hdu.edu.cn/showproblem.php?pid=1869 六度分离 Time Limit: 5000/1000 MS (Java/Others)    Memory ...

随机推荐

  1. 【视频】零基础学Android开发:蓝牙聊天室APP(一)

    零基础学Android开发:蓝牙聊天室APP第一讲 1. Android介绍与环境搭建:史上最高效Android入门学习 1.1 Google的大小战略 1.2 物联网与云计算 1.3 智能XX设备 ...

  2. UVA 4855 Hyper Box

    You live in the universe X where all the physical laws and constants are different from ours. For ex ...

  3. 6.26的二分(久违的AC)

    /* codevs 2765 很明显的二分 半年不写代码 超丑 怎么能忍, */ #include<cstdio> #include<algorithm> #define ma ...

  4. 关于move_uploaded_file()出错的问题

    move_upload0ed_file()函数返回參数较少.可是引起出错的原因却有非常多,所以对于刚開始学习的人难免会遇到问题. 出错原因大概有下面三点: 1.假设检測到文件不是来自post上传.这个 ...

  5. 2017-3-12 leetcode 167 209 216

    ---恢复内容开始--- 对于每次开机avast喊出的“已经检测到危害”实在忍无可忍了(它只能检测到不能根除很气..)于是重装了系统,回到了win10感觉不赖. =================== ...

  6. php gd

    imagecopy() 函数用于拷贝图像或图像的一部分. imagecopyresized() 函数用于拷贝部分图像并调整大小. imagecopy() imagecopy() 函数用于拷贝图像或图像 ...

  7. [luogu P5349] 幂 解题报告 (分治FFT)

    interlinkage: https://www.luogu.org/problemnew/show/P5349 description: solution: 设$g(x)=\sum_{n=0}^{ ...

  8. Docker修改hosts方法

    方法一: 直接进入容器中修改/etc/hosts 缺点:重启容器后,增加的内容会丢失 方法二: 制作镜像的时候,直接修改. 限制: 需要是root用户,需要在容器中安装sudo 增大了镜像大小 方法三 ...

  9. GStreamer基础教程01 - Hello World

    摘要 在面对一个新的软件库时,第一步通常实现一个“hello world”程序,来了解库的用法.对于GStreamer,我们可以实现一个极简的播放器,来了解GStreamer的使用. 环境配置 为了快 ...

  10. Eigen3

    Eigen用源码的方式提供给用户使用,在使用时只需要包含Eigen的头文件即可进行使用. Eigen: C++开源矩阵计算工具——Eigen的简单用法 http://blog.csdn.net/aug ...