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 ...
随机推荐
- C/C++中new关键字是否加括号的区别
代码: #include <iostream> using namespace std; class A{ public: int a; }; int main(){ A *a1 = ne ...
- (原)torch使用caffe时,提示CUDNN_STATUS_EXECUTION_FAILED
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6230227.html 提前说明:此文不能真正解决该问题,具体原因我也不知道... 以前使用某台电脑A上 ...
- YUI 之getLocation
关于Y.getLocation的简介是 Returns the `location` object from the window/frame in which this YUI instance o ...
- MySQL主从问题
Mysql数据库主从心得整理 管理mysql主从有2年多了,管理过200多组mysql主从,几乎涉及到各个版本的主从,本博文属于总结性的,有一部分是摘自网络,大部分是根据自己管理的心得和经验 ...
- DataTables自定义筛选器
/* Custom filtering function which will search data in column four between two values */ $.fn.dataTa ...
- iPhone开发 数据持久化总结(终结篇)—5种数据持久化方法对比
iPhone开发 数据持久化总结(终结篇)—5种数据持久化方法对比 iphoneiPhoneIPhoneIPHONEIphone数据持久化 对比总结 本篇对IOS中常用的5种数据持久化方法进行简单 ...
- android特效
http://houxiyang.com/archives/89/ http://blog.csdn.net/hjj0212/article/details/8535817 http://www.li ...
- 格式化用jad反编译混淆过的代码,能去大部分错误 (zhuanzai)
http://blog.csdn.net/chruan/article/details/8484783
- Keil中LIB库的作用、生成与调用
LIB库有什么用,一个简单的例子就是Silicon Labs为C8051F单片机USB提供的USBXpress LIB库了,如USB发送数据.接收数据等,都是通用性很强的函数,但因为保密的原因,这个函 ...
- ASP.NET WEB API回发到客户端消息体的格式化
首先基于SOA的消息通信基本都是按照一个统一的协议规范进行交互,那么必须定义消息体.不同的交互结构设计了不同的消息体. 业界统一使用的SOAP是一种规范的XML消息内容.例如在WCF中返回的结果. 随 ...