#C2226. Serpentine River Length Calculation

    ID: 45519 Type: Default 1000ms 256MiB

Serpentine River Length Calculation

Serpentine River Length Calculation

You are given the description of a serpentine river divided into n segments. The river is described by a sequence of n+1 points in the 2D plane, where each consecutive pair of points defines a segment of the river. In addition, each segment has associated its width and depth. The actual computation for the river only takes into account the width.

For the i-th segment, let the endpoints be \( (x_i, y_i) \) and \( (x_{i+1}, y_{i+1}) \). The Euclidean distance \( d_i \) is calculated by:

[ d_i = \sqrt{(x_{i+1} - x_i)^2 + (y_{i+1} - y_i)^2} ]

The adjusted length of the segment is defined as:

[ \text{adjusted_length}_i = d_i \times \left(1 + \frac{w_i}{1000}\right), ]

where \( w_i \) is the width of the segment. The depth value is provided but is not used in the calculation.

Your task is to compute and output the sum of these adjusted lengths for all segments in the river.

inputFormat

The input is read from standard input (stdin) and has the following format:

  • An integer n denoting the number of segments.
  • n+1 lines follow, each containing two space-separated numbers representing the coordinates \( x \) and \( y \) of the river's endpoints.
  • n lines follow, each containing two space-separated numbers: the first is the width \( w \) of the segment and the second is the depth \( d \) (note: depth is not used in the calculation).

All inputs are provided via stdin.

outputFormat

Output a single floating-point number representing the total adjusted length of the river. The output should be printed to standard output (stdout).

## sample
1
0 0
3 4
2 50
5.01