xtu summer individual-4 B - Party All the Time
Party All the Time
This problem will be judged on HDU. Original ID: 4355
64-bit integer IO format: %I64d Java class name: Main
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
1
4
0.6 5
3.9 10
5.1 7
8.4 10
Sample Output
Case #1: 832
Source
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <cstdlib>
#include <string>
#include <set>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = ;
const double exps = 1e-;
int n;
double x[maxn],w[maxn];
double test(double px){
double sum = ;
for(int i = ; i < n; i++)
sum += fabs(px-x[i])*fabs(px-x[i])*fabs(px-x[i])*w[i];
return sum;
}
int main(){
int t,i,j,k = ;
double low,high,mid,midd;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
low = INF;
high = -INF;
for(i = ; i < n; i++){
scanf("%lf %lf",x+i,w+i);
low = min(low,x[i]);
high = max(high,x[i]);
}
while(fabs(high - low) >= exps){
mid = (high+low)/2.0;
midd = (high+mid)/2.0;
if(test(mid)+exps < test(midd))
high = midd;
else low = mid;
}
printf("Case #%d: %.0f\n",k++,test(low));
}
return ;
}
xtu summer individual-4 B - Party All the Time的更多相关文章
- xtu summer individual 4 C - Dancing Lessons
Dancing Lessons Time Limit: 5000ms Memory Limit: 262144KB This problem will be judged on CodeForces. ...
- xtu summer individual 3 C.Infinite Maze
B. Infinite Maze time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- xtu summer individual 2 E - Double Profiles
Double Profiles Time Limit: 3000ms Memory Limit: 262144KB This problem will be judged on CodeForces. ...
- xtu summer individual 2 C - Hometask
Hometask Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Origin ...
- xtu summer individual 1 A - An interesting mobile game
An interesting mobile game Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on H ...
- xtu summer individual 2 D - Colliders
Colliders Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Origi ...
- xtu summer individual 1 C - Design the city
C - Design the city Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu D ...
- xtu summer individual 1 E - Palindromic Numbers
E - Palindromic Numbers Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %l ...
- xtu summer individual 1 D - Round Numbers
D - Round Numbers Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u D ...
- xtu summer individual 5 F - Post Office
Post Office Time Limit: 1000ms Memory Limit: 10000KB This problem will be judged on PKU. Original ID ...
随机推荐
- 正则表达式test报错 is not a function
var reg = "/^1[34578]\d{9}$/"; //错误格式,这是一个字符串 var reg2 = /^1[34578]\d{9}$/; //正确格式 reg .te ...
- Hadoop调度框架
大数据协作框架是一个桐城,就是Hadoop2生态系统中几个辅助的Hadoop2.x框架.主要如下: 1,数据转换工具Sqoop 2,文件搜集框架Flume 3,任务调度框架Oozie 4,大数 ...
- ubuntu下安装mongo扩展
安装openssl apt-get install openssl libssl-dev libssl0.9.8 libgtk2.0-dev 安装php-pear apt-get install ph ...
- 最简单的教程:在Ubuntu操作系统里安装Docker
Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化.容器是完全使用沙箱机制,相互之间不会有任何 ...
- 手把手教你免费把网站IP换成1.1.1.1/1.0.0.1
近日,Cloudflare官方发文,与APNIC官方合作打算用IP1.1.1.1推出速度更快.私密性更强的DNS Cloudflare 运行全球规模最大.速度最快的网络之一. APNIC 是一个非营利 ...
- HashSet LinkedHashSet TreeSet 分析
1.HashSet分析 hashset 底层是hash表,就是hashMap,是无序的,唯一的.也就是说,它的底层其实就是一个HashMap key 值的组成值.所以具有唯一性. public Ha ...
- 富通天下(T 面试)
1.Mybatis的分页查询是怎么实现的? 交流: A:我们是通过PageHelper插件实现的 B:你说下原生SQL应该怎么写? A:某段查询SQL,实现分页需要使用limit关键字,改变下标和页码 ...
- Modal 下面的 v-model 就是显示不显示 true 或 false
Modal 下面的 v-model 就是显示不显示 true 或 false
- Qt setWindow setViewPort
painter.setWindow(-50, -50, 100, 100); //表示x,y坐标不变,可视的窗口移动到(-50,-50)的位置.同时在x,y方向产生factorx= (window.w ...
- 包含绑定变量的sql进行调优需注意一点
拿1个sql举个例子,我只贴出了where后面部分 实际环境中有init_date 和direct_no的组合索引IDX_DATE_NO 上诉标红处,:b3=0 和:b3<>0这两种情况o ...