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 ...
随机推荐
- Include,Forward,sendRedirct的区别(转)
三者在servlet中的最大区别是: Include和Forward:将当前请求转到另外一个JSP或者servlet处理. sendRedirct:将当前请求返回到浏览器,带上要redirect的UR ...
- Collection2
- python_面向对象进阶(7)
第1章 面向对象特性—继承(补充) 1.1 接口类.抽象类介绍 1.2 接口类 1.3 接口类应用过程 1.3.1 第一版:完成多种支付方式接口 1.3.2 第二版: 归一化设计,统一支付方式 1.3 ...
- Suricata的性能
不多说,直接上干货! 见官网 https://suricata.readthedocs.io/en/latest/performance/index.html Docs » 7. Performanc ...
- Ionic之增加样式会自动换行解决方案
设置样式的时候,引用自身的样式,能正常显示,但是引用自定义样式显示的时候,竟然或自动换行,好尴尬. 原本代码: $('.codeSuccess').css({'display':'block'}); ...
- java 自定义注解,并使用示例
场景: 对需要校验 手机验证码和短信验证码的controller方法添加 自定义的注解 @CheckType 1. 定义注解 /** * 需要短信.验证码验证方法上的注解 * date: 2018年 ...
- 定时器、线程queue、进程池和线程池
1.定时器 指定n秒后,执行任务 from threading import Timer,current_thread import os def hello(): print("%s he ...
- CSS层叠的问题、标准文档流、伪类选择器
一.层叠的问题 CSS有两个性质: 1.继承性 2.层叠性:选择器的一种选择能力,谁的权重大就选谁 层叠性又分为: 1).选不中:走继承性 (font.color.text.) 继承性的权重是0 若 ...
- 《深入理解Java虚拟机》读书笔记
堆分配参数: -XX:+PrintGC 使用该参数,虚拟机启动后,只要遇到GC就会打印日志: -XX:+UseSerialGC 配置串行回收器: -XX:+PrintGCDeltails 可以查看详细 ...
- Eclipse--java.lang.OutOfMemoryError: PermGen space
这一段时间,Eclipse总是死掉,几乎是稍微操作快一点就会死掉,几分钟一次,搞得人郁闷至极.浪费了不少时间,在网上搜了下,看到很多朋友也出现类似的情况,在网上求救,但是网上的办法都只是说通过修改ec ...