SGU114-Telecasting station
|
114. Telecasting station time limit per test: 0.5 sec. Every city in Berland is situated on Ox axis. The government of the country decided to build new telecasting station. After many experiments Berland scientists came to a conclusion that in any city citizens displeasure is equal to product of citizens amount in it by distance between city and TV-station. Find such point on Ox axis for station so that sum of displeasures of all cities is minimal. Input Input begins from line with integer positive number N (0<N<15000) – amount of cities in Berland. Following N pairs (X, P) describes cities (0<X, P<50000), where X is a coordinate of city and P is an amount of citizens. All numbers separated by whitespace(s). Output Write the best position for TV-station with accuracy 10-5. Sample Input 4 Sample Output 3.00000 |
|
题意是说,有个国家的城市之间要建个公交(我英语不好、翻译可能会跑偏、也可能是电视塔、也可能是别的、我也不知道是啥),然后有一个不满意度,咱们自己想想也知道,肯定都喜欢把地铁站设在自己家门口。然后这个不满意度=城市的人数*这个站的位置。。。然后的然后、我也不会做这个题,直接上理论:数学家说,这是一个带权中位数问题,具体内容见 http://baike.baidu.com/link?url=NZbFTsJCCn_jsx8W24aLu6XGEVdpDH0hpO_SIzeCF7vFi_Nz-xV4pe7tzuJBpQsQSzoa719FmHYb3lr7QKV3q_ 这个讲的很明白了。然后,下面的代码就自然手到擒来了!!! #include<iostream> |
SGU114-Telecasting station的更多相关文章
- sgu114. Telecasting station 难度:1
114. Telecasting station time limit per test: 0.25 sec. memory limit per test: 4096 KB Every city in ...
- 数学 + 带权中位数 - SGU 114 Telecasting station
Telecasting station Problem's Link Mean: 百慕大的每一座城市都坐落在一维直线上,这个国家的政府决定建造一个新的广播电视台. 经过了许多次试验后,百慕大的科学家们 ...
- Telecasting station - SGU 114(带劝中位数)
题目大意:在一个数轴上有N个点,每个点都有一个权值,在这个数轴上找一个点,是的每个点到这个点的距离之和乘上权值的总和最小. 分析:以前也遇到过类似的问题,不过并不知道这是带权值的中位数问题,百度百科有 ...
- SGU 114.Telecasting station
题意: 百慕大的每一座城市都坐落在一维直线上.这个国家的政府决定建造一个新的广播电视台.经过了许多次试验后,百慕大的科学家们提出了一个结论,在每座城市的不满意度等于这座城市的市民数与这座城市与广播电视 ...
- SGU 114. Telecasting station 三分or找中位数
题目链接点这儿 一開始想都没想...直接上了三分...结果...sample的答案不一样...可是过了...然后又看了看. . . 发现这不就是高中或者初中出过的求中位数的题么. . .直接找到这些的 ...
- SGU 114
114. Telecasting station time limit per test: 0.25 sec. memory limit per test: 4096 KB Every city in ...
- SGU题目总结
SGU还是个不错的题库...但是貌似水题也挺多的..有些题想出解法但是不想写代码, 就写在这里吧...不排除是我想简单想错了, 假如哪位神犇哪天发现请告诉我.. 101.Domino(2015.12. ...
- SGU 分类
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...
- [LeetCode] Gas Station 加油站问题
There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You ...
随机推荐
- BZOJ 1216: [HNOI2003]操作系统( 优先队列 )
按题意用priority_queue模拟即可 ---------------------------------------------------------------------- #inclu ...
- Android空指针异常的常见情况
把我经常遇到的nullpoitException写在这里,以便以后自己查找原因. 1.用findViewById(param )的方法获取一个view对象的时候,有的时候其实应该是获取一个layout ...
- Executor框架
Executor框架是指java5中引入的一系列并发库中与executor相关的功能类,包括Executor.Executors.ExecutorService.CompletionService. ...
- 乐观锁&悲观锁
悲观&乐观,只是对数据加锁的时机与粒度. 悲观锁(Pessimistic Lock), 顾名思义,就是很悲观,每次去拿数据的时候都认为别人会修改,所以每次在拿数据的时候都会上锁,这样别人想拿这 ...
- javascript语言精粹:继承
继承提供了2个有用的任务: 1.代码重用 2.引入了一套类型系统的规范,因为程序员无需编写显示类型转换的代码,他们的工作量将大大减轻.这是一件很好的事情,应为类型转换会丧失类型系统在安全上的优势. 在 ...
- 常见makefile写法
原文地址:blog.csdn.net/ghostyu/article/details/7755177 1.目标名称,摆脱手动设置目标名称 TARGET = $(notdir $(CURDIR)) al ...
- debian支持ll命令
debian支持ll命令 $ ll -bash: ll: command not found 没有ll这个命令.尽管也知道ll事实上 是ls -l 这个命令的别名,可是总感觉不是非常习惯.由于之前一直 ...
- Lucene核心--构建Lucene搜索(下篇,理论篇)
2.1.6 截取索引(Indextruncate) 一些应用程序的所以文档的大小先前是不知道的.作为控制RAM和磁盘存储空间的使用数量的安全机制,你可能想要限制每个字段允许输入索引的输入数量.一个大的 ...
- C语言,链表反转
倒序思路:依次把后面的节点移往头部. struct Node{ struct Node* next; int data; }; typedef struct Node NODE; NODE* inve ...
- 工具类CTools实现字符编码转换和获取当前路径
class CTools { public: CTools(void); public: ~CTools(void); public: static std::string UNICODE_to_UT ...