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 ...
随机推荐
- nexus启动报错----->错误 1067: 进程意外终止。
1.今天启动nexus报错: 2.错误信息 错误 1067: 进程意外终止. 3.检查发现我之前把jdk升级了.然而nexus之前指定的jdk将不再生效. 4.解决办法 找到nexus安装目录 修改b ...
- 局部变量,全局变量,extend,static
main.c #include <stdio.h> #include "zs.h" /* 局部变量是定义在函数.代码块.函数形参列表.存储在栈中,从定义的那一行开始作用 ...
- 2.2Shiro架构
- thinkphp 具体常量,在view里面使用
1 2 3 4 5 6 7 8 9 '__TMPL__' => APP_TMPL_PATH, // 项目模板目录 '__ROOT__' => __ROOT__, ...
- maven 打包jar && lib
一.springboot 打包成jar 1.pom.xml <build> <!-- jar的名称--> <finalName>shiro</finalNam ...
- ASCII和ASCII扩展表
- 前端-Angular思维导图笔记
看不清的朋友右键保存或者新窗口打开哦!喜欢我可以关注我,还有更多前端思维导图笔记
- hdu1829 A Bug's Life 基础种类并查集
题目的大意可以理解为:A爱B,B爱C ……给出一系列爱恋的关系,推断有没有同性恋. 思路是把相同性别的归为一个集合(等价类),异性的异性为同性. #include<iostream> #i ...
- ZBrush中如何将一个模型应用在不同的图层
我们经常会使用ZBrush®中的插入笔刷来实现快速建模,或者使用Insert笔刷创建人物四肢,那么在使用这些笔刷时,它默认是和所接触模型同在一个Subtool,如果您需要不同的材质或者雕刻手法,那么就 ...
- Python 3 print 函数用法总结
Python 3 print 函数用法总结 1. 输出字符串和数字 print("runoob") # 输出字符串 runoob print(100) ...