hdu4355 三分
Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
Now give you every spirit's weight and location,find the best place to celebrate the harvest which make the sum of unhappyness of every spirit the least.
Input
Output
Sample Input
4
0.6 5
3.9 10
5.1 7
8.4 10
Sample Output
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;
const int maxn=50000+100;
#define eps 1e-8
const int inf=0xfffffff;
const double pi=acos(-1.0);
struct nod
{
double x;
double w;
};
nod s[maxn];
int n;
double len(double a)
{
double sum=0;
for(int i=0;i<n;i++)
{
double d=fabs(s[i].x-a);
sum+=d*d*d*s[i].w;
}
return sum;
}
int kase=0;
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
double l=inf,r=-inf;
for(int i=0;i<n;i++)
{
scanf("%lf%lf",&s[i].x,&s[i].w);
l=min(l,s[i].x);
r=max(r,s[i].x);
}
while(l+eps<=r)
{
double mid=(l+r)/2;
double mmid=(mid+r)/2;
double t1=len(mid),t2=len(mmid);
if(t1<=t2) r=mmid;
else l=mid;
}
printf("Case #%d: %.lf\n",++kase,len(l));
}
return 0;
}
hdu4355 三分的更多相关文章
- HDU4355 三分查找
/* * 三分查找 */ #include<cstdio> #include<cmath> #define eps 1e-6 //typedef __int64 LL; i ...
- hdu3714 三分找最值
Error Curves Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- BZOJ 1857 传送带 (三分套三分)
在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段AB和线段CD.lxhgww在AB上的移动速度为P,在CD上的移动速度为Q,在平面上的移动速度R.现在lxhgww想从 ...
- hdu 4717(三分求极值)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 思路:三分时间求极小值. #include <iostream> #include ...
- HDU2438 数学+三分
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- 三分之一的程序猿之社交类app踩过的那些坑
三分之一的程序猿之社交类app踩过的那些坑 万众创新,全民创业.哪怕去年陌生人社交不管融资与否都倒闭了不知道多少家,但是依然有很多陌生人社交应用层出不穷的冒出来.各种脑洞大开,让人拍案叫起. 下面我们 ...
- 基于jPlayer的三分屏制作
三分屏,这里的三分屏只是在一个播放器里同时播放三个视频,但是要求只有一个控制面板同时控制它们,要求它们共享一个时间轨道.这次只是简单的模拟了一下功能,并没有深入的研究. 首先,需要下载jPlayer, ...
- 【BZOJ-1857】传送带 三分套三分
1857: [Scoi2010]传送带 Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 1077 Solved: 575[Submit][Status][ ...
- ACM : HDU 2899 Strange fuction 解题报告 -二分、三分
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
随机推荐
- isArray
判断一个玩意是不是数组: (1)新方法:Array.isArray(); (2)旧方法:toString(); <!doctype html> <html lang="en ...
- curl抓取信息
<?php $hotel = new curl(false,0); $str = $hotel -> post("http://www.todayinns.com/login.p ...
- js版iphone通讯录分组列表效果
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content ...
- Python正则匹配递归获得给出目录下的特定类型的文件小技巧
需求是酱的: 输入一个目录,这个目录包含检测目录的必备信息但不准确需要获得后加工一下,如给出目录:C:\Program Files\Common Files\DESIGNER,需要检测的目录是:C:\ ...
- activiti 5.17 流程图中文乱码问题
1. 流程图中任务中的中文乱码显示问题. 解决方法:设置processEngineConfiguration中的两个字体属性,例如: <bean id="processEngine ...
- cf B. Valera and Contest
http://codeforces.com/contest/369/problem/B 先对k个处理,先处理sk%k个为sk/k+1,如果sk/k==0,k个数都为sk/k:对与剩下的数也按照同样的方 ...
- windows下使用批处理调用exe和服务
手动调用exe或者启动服务很麻烦,可以使用.bat批处理文件,双击运行即可.步骤如下:创建一个新的txt文件但是保存成.bat结尾的文件(选择用记事本打开编写命令),输入代码内容格式如下: @echo ...
- logstash tomcat catalina.out zabbix 插件不会引起崩溃
input { file { type => "zj_api" path => ["/data01/applog_backup/zjzc_log/zj-api ...
- 传智播客8月C/C++基础班开班
秋天已经向我们走来,在这个充满收获的季节里,大家齐聚传智C/C++学院这个大家庭,无论你曾经从事什么工作,都拥有着一颗热爱C/C++的心,为了自己心中的梦想,大家要付出百倍的努力,要做到&quo ...
- 【转】Ubuntu重装,直接进win7,不进linux的解决方案(添加Ubuntu启动菜单)
原文网址:http://my.oschina.net/u/1377657/blog/281875 本人重装了Ubuntu12.04.4 LTS, 将Ubuntu启动项放在了/boot分区里面,启动的时 ...