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

#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. 【撸码caffe 二】 blob.hpp

    Blob类是caffe中对处理和传递的实际数据的封装,是caffe中基本的数据存储单元,包括前向传播中的图像数据,反向传播中的梯度数据以及网络层间的中间数据变量(包括权值,偏置等),训练模型的参数等等 ...

  2. 【BZOJ2806】【CTSC2012】Cheat 广义后缀自动机+二分+Dp

    题目 题目在这里 思路&做法 我们先对标准作文库建广义后缀自动机. 然后对于每一篇阿米巴的作文, 我们首先把放到广义后缀自动机跑一遍, 对于每一个位置, 记录公共子串的长度\((\)即代码和下 ...

  3. Java登录界面简单设计

    package cn.com.view; import java.awt.Color; import java.awt.Font; import java.awt.SystemColor; impor ...

  4. POJ 1200 Hash

    我的hash从来没写对过........ (白学了快一年OI --原来连个hash都没写对过) 但是 但是 今天是一个值得纪念的日子. 看看标题 我竟然在写hash的题解. (好了好了 废话少说) 题 ...

  5. Codeforces Round #198 (Div. 2)C,D题解

    接着是C,D的题解 C. Tourist Problem Iahub is a big fan of tourists. He wants to become a tourist himself, s ...

  6. JAVA课设——中药古籍《太平圣惠方》数据处理与分析系统

    一.配置JAVA环境 本次课设是在Windows 10(64bit)平台上实现的,所以首先得配置下JAVA环境. 步骤一:先下载一个JDK(1.7)安装包,安装好JDK: 步骤二:JDK环境配置(由于 ...

  7. Docker 配置与实践清单

    https://mp.weixin.qq.com/s/yeEkF5DKa9IjmIvuzOTT3g

  8. RoIPooling与RoIAlign的区别

    一.RoIPooling与RoIAlign 1.1.RoIPooling 通过对Faster RCNN的学习我妈了解的RolPooling可以使生成的候选框region proposal映射产生固定大 ...

  9. 关于CommandTimeOut

    指示在终止尝试和产生错误之前执行命令期间需等待的时间. 设置和返回值 设置或返回长整型值,该值指示等待命令执行的时间(单位为秒).默认值为 30. 说明 Connection 对象或Command 上 ...

  10. vsftp进阶-锁定目录

    把用户锁定到特定的目录下面: 一.配置文件: #grep -Ev "^#|^$" /etc/vsftpd/vsftpd.conf anonymous_enable=NOlocal_ ...