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 ...
随机推荐
- [ACM] HDU 5086 Revenge of Segment Tree(全部连续区间的和)
Revenge of Segment Tree Problem Description In computer science, a segment tree is a tree data struc ...
- Oracle 10G 中的"回收站"
在Oracle 10g数据库中,引入了一个回收站(Recycle Bin)的数据库对象. 回收站,从原理上来说就是一个数据字典表,放置用户Drop掉的数据库对象信息.用户进行Drop操作的对象并没有被 ...
- SpringAop中JoinPoint对象
来自:http://blog.csdn.net/it_zouxiang/article/details/52576917 JoinPoint的用法 JoinPoint 对象 JoinPoint对象封装 ...
- guice 整合ninja framework(七)
ninja是一个优秀的,轻量级的mvc框架,它与google guice整合比较好.下面看一下例子: 我们在web.xml 配置一下: <listener> <listener-cl ...
- hibernate dao 公共方法
package com.dao.impl; import java.lang.reflect.ParameterizedType; import java.util.Collection; impor ...
- SurfaceView加载长图
1:SurfaceView加载长图,移到.可以充当背景 效果截图 2:View (淡入淡出动画没实现:记录下) package com.guoxw.surfaceviewimage; import a ...
- SVD分解.潜语义分析.PythonCode
原文链接:http://www.cnblogs.com/appler/archive/2012/02/02/2335886.html 原始英文链接:http://www.puffinwarellc.c ...
- .apply .call方法的区别及使用 .apply第二个参数为数组,.call第二个参数为参数列表, 相同点:第一个参数都为Function函数内部的this对象.
Function.apply(obj,args)方法能接收两个参数 obj:这个对象将代替Function类里this对象 args:这个是数组,它将作为参数传给Function(args--> ...
- Apex语言(二)变量与常量
1.变量 凡是交给计算运算(处理)的数据就是变量,用来保存参加运算的数据和计算结果. 变量由变量名来标识. 变量名由字母数字和下划线组成,不能以数字开头. [正确]number,number1,num ...
- vc++如何创建程序-构造函数
如果给Animal带参,则提示没有缺省的构造函数了,缺省就是不带参数的 改进:从子类当中向基类传递代参的,这样他就会给Animal传递400,300 对一个常量来调用 #include<iost ...