HDU 4355
只能说感觉是三分吧,因为两端值肯定是最大的,而中间肯定存在一点使之最小,呃,,,,猜 的。。。
#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的更多相关文章
- codeforces 782B The Meeting Place Cannot Be Changed+hdu 4355+hdu 2438 (三分)
B. The Meeting Place Cannot Be Change ...
- hdu 4355 Party All the Time(三分搜索)
Problem Description In the Dark forest, there is a Fairy kingdom where all the spirits will go toget ...
- HDU 4355 Party All the Time (三分求极值)
题意:给定x轴上有n个点,每一个点都有一个权值,让在x轴上选一个点,求出各点到这个点的距离的三次方乘以权值最小. 析:首先一开始我根本不会三分,也并没有看出来这是一个三分的题目的,学长说这是一个三分的 ...
- HDU 4355.Party All the Time-三分
Party All the Time Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- HDU 4355——Party All the Time——————【三分求最小和】
Party All the Time Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- HDU 4355 Party All the Time(三分|二分)
题意:n个人,都要去參加活动,每一个人都有所在位置xi和Wi,每一个人没走S km,就会产生S^3*Wi的"不舒适度",求在何位置举办活动才干使全部人的"不舒适度&quo ...
- HDU 4355:Party All the Time(三分模板)
Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s) ...
- hdu4355 三分
F - 三分 Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:32768KB 64bit I ...
- hdu 1869 (Floyd)
http://acm.hdu.edu.cn/showproblem.php?pid=1869 六度分离 Time Limit: 5000/1000 MS (Java/Others) Memory ...
随机推荐
- poj 3259-- Wormholes(SPFA)
...
- [Plugin] JQuery.uploadify上传文件插件的使用详解For ASP.NET
URL:http://www.cnblogs.com/xiaopin/archive/2010/01/21/1653523.html 今天下午整理文件上传的例子,感觉收集到的例子都很不人性话,后来找到 ...
- MySQL架构与SQL执行流程
MySQL架构设计 下面是一张MySQL的架构图: 上方各个组件的含义如下: Connectors 指的是不同语言中与SQL的交互 Management Serveices & Utiliti ...
- HBase编程 API入门系列之delete.deleteColumn和delete.deleteColumns区别(客户端而言)(4)
心得,写在前面的话,也许,中间会要多次执行,连接超时,多试试就好了. delete.deleteColumn和delete.deleteColumns区别是: deleteColumn是删除某一个列簇 ...
- unity3d 让物体移动到点击位置
using UnityEngine; using System.Collections; public class test : MonoBehaviour { //在场景中鼠标点击地面后,角色可以移 ...
- layui新手使用
1,首先最重要的是引入官方的layui.js layui.css文件 2,在自己的项目中新建一个目录 再在该目录下建一个js文件,js中写入 layui.define(['layer', 'form ...
- 使用Flask和Bootstrap构建博客系统(1) - 准备篇
技术栈 macOS10.12.5 Python2.7.13 Bootstrap4.0.0-beta.2 virtualenv virtualenvwrapper 安装Python2.7.13 下载Bo ...
- Redis 四:存储类型之散列类型
1.散列类型表达方式简介: =========================================== 键 字段 值 =================================== ...
- LoadRunner时间戳函数web_save_timestamp_param
举例:1520822348346(13位,毫秒级) 做时间戳的目的是为了JS缓存和防止CSRF,在LR中可以简单的使用下面这个函数 web_save_timestamp_param 来生成时间戳 ...
- redis启动出错 Creating Server TCP listening socket 127.0.0.1:6379: bind: No error解决办法
windows下安装Redis第一次启动报错: [2368] 21 Apr 02:57:05.611 # Creating Server TCP listening socket 127.0.0.1: ...