World Finals 2017
Need for Speed
Sheila is a student and she drives a typical student car: it is old, slow, rusty, and falling apart. Recently, the needle on the speedometer fell off. She glued it back on, but she might have placed it at the wrong angle. Thus, when the speedometer reads ss, her true speed is s+cs+c, where cc is an unknown constant (possibly negative).
Sheila made a careful record of a recent journey and wants to use this to compute cc. The journey consisted of nn segments. In the ithith segment she traveled a distance of didi and the speedometer read sisi for the entire segment. This whole journey took time tt. Help Sheila by computing cc.
Note that while Sheila’s speedometer might have negative readings, her true speed was greater than zero for each segment of the journey.
Input
The first line of input contains two integers nn (1≤n≤10001≤n≤1000), the number of sections in Sheila’s journey, and tt(1≤t≤1061≤t≤106), the total time. This is followed by nn lines, each describing one segment of Sheila’s journey. The ithith of these lines contains two integers didi (1≤di≤10001≤di≤1000) and sisi (|si|≤1000|si|≤1000), the distance and speedometer reading for the ithith segment of the journey. Time is specified in hours, distance in miles, and speed in miles per hour.
Output
Display the constant cc in miles per hour. Your answer should have an absolute or relative error of less than 10−610−6.
| Sample Input 1 | Sample Output 1 | 
|---|---|
3 5  | 
3.000000000  | 
| Sample Input 2 | Sample Output 2 | 
|---|---|
4 10  | 
-0.508653377  | 
wa了好久了,搞不懂二分范围,以为-1000到1e6+1000就够了,我一开大范围反而得不到答案
通过读题列出通项公式,很容易想到二分操作
#include<bits/stdc++.h>
#define eps 1e-8
using namespace std;
typedef long long ll;
double a[],b[];
int n,m;
double solve(){
double l=-<<,r=<<,mid;
for(int i=;i<n;i++)
l=max(l,-b[i]);
for(int i=;i<;i++){
mid=(l+r)/;
double sum=0.0;
for(int j=;j<n;j++){
sum+=a[j]/(mid+b[j]);
}
if(sum-m>) l=mid;
else r=mid;
}
return r;
}
int main(){
cin>>n>>m;
for(int i=;i<n;i++)
cin>>a[i]>>b[i];
double ans=solve();
printf("%.8lf\n",ans);
}
World Finals 2017的更多相关文章
- World Finals 2017爆OJ记
		
Day-Inf: 去年China-Final一道数据结构题的FB送我进WF. 今年课表意外地满,好几天都是早上8点一直上课上到晚上9点,作业也相对较多.敝队大约每个星期只能训练一个下午,有时候甚至一整 ...
 - World Finals 2017 (水题题解)
		
看大佬做2017-WF,我这种菜鸡,只能刷刷水题,勉强维持生活. 赛后补补水题. 题目pdf链接,中文的,tls翻译的,链接在这里 个人喜欢在vjudge上面刷题. E Need for Speed ...
 - #6472. 「ICPC World Finals 2017」难以置信的任务 Mission Improbable
		
可以简化一下问题,假设Patrick把箱子都拿走但是原来有箱子的位置留下一个,现在要放箱子使得每行每列最大值都满足,最少放多少个. 设第\(i\)行的最大值是\(H(i)\),第\(i\)列的是\(W ...
 - ZJOI2019一轮游记
		
Preface 期待已久的省选终于开始了233,关于之前的一些内容,在ZJOI2019一轮停课刷题记录都可以找到,这里不再赘述 ZJOI2019,Bless All Day -1 今天难得有休息,昨晚 ...
 - Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)
		
Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) 说一点东西: 昨天晚上$9:05$开始太不好了,我在学校学校$9:40$放 ...
 - Codeforces Gym 101471D Money for Nothing(2017 ACM-ICPC World Finals D题,决策单调性)
		
题目链接 2017 ACM-ICPC World Finals Problem D (这题细节真的很多) 把所有的(pi,di)按横坐标升序排序. 对于某个点,若存在一个点在他左下角,那么这个点就是 ...
 - Codeforces Round #403 (Div. 1, based on Technocup 2017 Finals)
		
Div1单场我从来就没上过分,这场又剧毒,半天才打出B,C挂了好几次最后还FST了,回紫了. AC:AB Rank:340 Rating:2204-71->2133 Div2.B.The Mee ...
 - [Russian Code Cup 2017 - Finals [Unofficial Mirror]]简要题解
		
来自FallDream的博客,未经允许,请勿转载,谢谢. Div1难度+ACM赛制 和几个大佬组队逛了逛 A.给一个大小为n的集合ai(1<=ai<=1000000),要求你构造一个大小 ...
 - 树的性质和dfs的性质    Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) E
		
http://codeforces.com/contest/782/problem/E 题目大意: 有n个节点,m条边,k个人,k个人中每个人都可以从任意起点开始走(2*n)/k步,且这个步数是向上取 ...
 
随机推荐
- 杂谈 什么是伪共享(false sharing)?
			
问题 (1)什么是 CPU 缓存行? (2)什么是内存屏障? (3)什么是伪共享? (4)如何避免伪共享? CPU缓存架构 CPU 是计算机的心脏,所有运算和程序最终都要由它来执行. 主内存(RAM) ...
 - eclipse版本要求修改
			
eclipse要求打开的是java1.6,而安装的是java1.7,这个时候需要修改配置 找到JAVA的安装路径, 点击前往-电脑-资源库-Java-javaVCirtualMachines-...- ...
 - uvm_subscriber——告诉她我们来过
			
Subscribers are basically listeners of an analysis port. They subscribe to a broadcaster and receive ...
 - watchguard 软件工程师内部招聘!
			
作为watchguard正式员工,现发布公司最近的招聘信息,待遇优厚,请符合条件的朋友和我联系并将简历发给我,我会尽早联系公司人力部门. 我的邮件:daibao91888@163.com 博客:htt ...
 - POJ 2831 Can We Build This One?
			
Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 1728 Accepted: 643 Case Time Limit: 2 ...
 - 洛谷 P1330 封锁阳光大学
			
题目描述 曹是一只爱刷街的老曹,暑假期间,他每天都欢快地在阳光大学的校园里刷街.河蟹看到欢快的曹,感到不爽.河蟹决定封锁阳光大学,不让曹刷街. 阳光大学的校园是一张由N个点构成的无向图,N个点之间由M ...
 - Java MiniUi datagrid加载数据时,如果使用virtualScroll="false",数据多一点可能就会加载不出来
			
datagrid的值为 virtualScroll="true" 问题解决.
 - 解决Genymotion2.8.1在拖动安装APK文件出现ARMtranslate错误
			
转载文章:http://blog.csdn.net/solo_talk/article/details/68488129 在新版本的genymotion中,我们拖动安装APK文件的时候会出现一个问题, ...
 - Freemarker入门小案例(生成静态网页的其中一种方式)
			
其实生成静态网页的方式有好多种,我昨天看了一下,Freemarker是其中一种,但是Freemarker现在我们都用得比较少了,现在用得ActiveMQ用来发送信息到静态页面,不过想了一下这个小东西, ...
 - [BZOJ2938]病毒 (AC自动机+dfs)
			
题目描述 二进制病毒审查委员会最近发现了如下的规律:某些确定的二进制串是病毒的代码.如果某段代码中不存在任何一段病毒代码,那么我们就称这段代码是安全的.现在委员会已经找出了所有的病毒代码段,试问,是否 ...