luogu#P6933. [ICPC2017 WF] Need for Speed

[ICPC2017 WF] Need for Speed

题目描述

Sheila is a student and she drives at ypical 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 ithi^{th} segment she traveled a distance of did_{i} and the speedometer read sis_{i} 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.

输入格式

The first line of input contains two integers n(1n1000)n (1 \le n \le 1 000) , the number of sections in Sheila's journey, and t(1t106),t (1 \le t \le 10^{6}), the total time. This is followed by nn lines, each describing one segment of Sheila's journey. The ithi^{th} of these lines contains two integers di(1di1000)d_{i} (1 \le d_{i} \le 1 000) and si(si1000)s_{i} (|s_{i}| \le 1 000) , the distance and speedometer reading for the ithi^{th} segment of the journey. Time is specified in hours, distance in miles, and speed in miles per hour.

输出格式

Display the constant cc in miles per hour. Your answer should have an absolute or relative error of less than 106.10^{−6}.

题目大意

在你面前的是一个坏掉的速度表,当显示速度为 ss km/h 时,实际速度为 s+cs+c km/h,cc 为固定的常数,为任意实数。你打算计算这个 cc,于是准备用这个速度表记录速度。现在你要走 nn 段路程,第 ii 段路程距离为 did_i 米,显示的指数为 sis_i km/h,总共路程用了 tt 小时。求 cc 的值。

你的答案应该与正确答案的差在 10610^{-6} 以内。

1n10001 \le n \le 10001t1061 \le t \le 10^61di10001 \le d_i \le 1000si1000|s_i| \le 1000

翻译者:一只书虫仔

3 5
4 -1
4 0
10 3

3.000000000

4 10
5 3
2 2
3 6
3 1

-0.508653377

提示

Time limit: 1 s, Memory limit: 512 MB.

spj provider:

/user/137367