主题链接:http://acm.hdu.edu.cn/showproblem.php?

pid=5073

Galaxy

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)

Total Submission(s): 768    Accepted Submission(s): 179

Special Judge

Problem Description
Good news for us: to release the financial pressure, the government started selling galaxies and we can buy them from now on! The first one who bought a galaxy was Tianming Yun and he gave it to Xin Cheng as a present.






To be fashionable, DRD also bought himself a galaxy. He named it Rho Galaxy. There are n stars in Rho Galaxy, and they have the same weight, namely one unit weight, and a negligible volume. They initially lie in a line rotating around their center of mass.



Everything runs well except one thing. DRD thinks that the galaxy rotates too slow. As we know, to increase the angular speed with the same angular momentum, we have to decrease the moment of inertia.



The moment of inertia I of a set of n stars can be calculated with the formula






where wi is the weight of star i, di is the distance form star i to the mass of center.



As DRD’s friend, ATM, who bought M78 Galaxy, wants to help him. ATM creates some black holes and white holes so that he can transport stars in a negligible time. After transportation, the n stars will also rotate around their new center of mass. Due to financial
pressure, ATM can only transport at most k stars. Since volumes of the stars are negligible, two or more stars can be transported to the same position.



Now, you are supposed to calculate the minimum moment of inertia after transportation.
 
Input
The first line contains an integer T (T ≤ 10), denoting the number of the test cases.



For each test case, the first line contains two integers, n(1 ≤ n ≤ 50000) and k(0 ≤ k ≤ n), as mentioned above. The next line contains n integers representing the positions of the stars. The absolute values of positions will be no more than 50000.
 
Output
For each test case, output one real number in one line representing the minimum moment of inertia. Your answer will be considered correct if and only if its absolute or relative error is less than 1e-9.
 
Sample Input
2
3 2
-1 0 1
4 2
-2 -1 1 2
 
Sample Output
0
0.5
 
Source
 
Recommend
 

Statistic | Submit | Discuss | Note

DP称号,我记得讨论点之一可。

版权声明:本文博客原创文章。博客,未经同意,不得转载。

hdu 5073 Galaxy(2014acm鞍山亚洲分部 D)的更多相关文章

  1. hdu 5073 Galaxy(2014acm鞍山亚洲分部 C)

    主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=5073 Galaxy Time Limit: 2000/1000 MS (Java/Others)   ...

  2. HDU 5073 Galaxy(2014鞍山赛区现场赛D题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5073 解题报告:在一条直线上有n颗星星,一开始这n颗星星绕着重心转,现在我们可以把其中的任意k颗星星移 ...

  3. HDU 5073 Galaxy (2014 Anshan D简单数学)

    HDU 5073 Galaxy (2014 Anshan D简单数学) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5073 Description G ...

  4. hdu 5073 Galaxy(2014 鞍山现场赛)

    Galaxy                                                                   Time Limit: 2000/1000 MS (J ...

  5. 2014 Asia AnShan Regional Contest --- HDU 5073 Galaxy

    Galaxy Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=5073 Mean: 在一条数轴上,有n颗卫星,现在你可以改变k颗 ...

  6. ACM学习历程—HDU 5073 Galaxy(数学)

    Description Good news for us: to release the financial pressure, the government started selling gala ...

  7. HDU 5073 Galaxy(Anshan 2014)(数学推导,贪婪)

    Galaxy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total S ...

  8. hdu 5073 Galaxy 数学 铜牌题

    0.5 题意:有n(n<=5e4)个质点位于一维直线上,现在你可以任意移动其中k个质点,且移动到任意位置,设移动后的中心为e,求最小的I=(x[1]-e)^2+(x[2]-e)^2+(x[3]- ...

  9. HDU 5073 Galaxy (数学)

    Galaxy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Su ...

随机推荐

  1. c# socket udp广播

    一.广播消息 由于Tcp是有连接的,所以不能用来发送广播消息.发送广播消息,必须用到Udp,Udp可以不用建立连接而发送消息.广播消息的目的IP地址是一种特殊IP地址,称为广播地址.广播地址由IP地址 ...

  2. 指定为文件头部Expires要么Cache-Control

    Cache-Control :private,no-cache.must-revalidate,max-age Expires指定页面过期时间 response.setContentType(&quo ...

  3. 【Android进阶】Android程序与JavaScript之间的简单调用

    本篇将讲解一个简单的Android与JavaScript之间的简单调用的小程序 效果图 工程结构 HTMLActivity.java代码 package com.example.javatojs; i ...

  4. 作为一个新人,如何学习嵌入式Linux?

    作为一个新人.如何学习嵌入式Linux?我一直在问太多次,特写文章来回答这个问题. 在学习嵌入式Linux之前.肯定要有C语言基础.汇编基础有没有无所谓(就那么几条汇编指令,用到了一看就会).C语言要 ...

  5. Java设计模式菜鸟系列(两)建模与观察者模式的实现

    转载请注明出处:http://blog.csdn.net/lhy_ycu/article/details/39755577 观察者(Observer)模式定义:在对象之间定义了一对多的依赖关系,这样一 ...

  6. mysql语句中使用like后面的%(百分号)的问题

    问题:mysql语句中使用like后面的%(百分号) 是不是越多运行效率越慢! 总用时:0.0489秒 0.0691 0.0485 0.0467 SELECT `goods_name`, `goods ...

  7. Swift UI学习UITableView and protocol use

    Models: UserModel.swift Views: UserInfoCell.swift Controllers: RootViewController.swift, DetailViewC ...

  8. Cocos2d-iPhone V3 (1) 其基本程序常用的行动框架和介绍

    Cocos2d-iPhone V3 (1) 其基本程序常用的行动框架和介绍 博客:http://blog.csdn.net/prevention 笔者:犀利哥 - 第一部分:一个 Cocos2d-iP ...

  9. 数组名取地址所算数运算应注意的&quot;trap&quot;

    数组名取地址所算数运算应注意的"trap" 直接看代码: #include <stdio.h> int main() { int array[5]; printf(&q ...

  10. GitBook 配置说明

    1. 下载并安装 npm node-v0.12.0.pkg http://nodejs.org/download/ 2. 安装 gitbook $ sudo npm install gitbook-c ...