Sum of the distance
Practice
3.6 (22 votes)
Mathematics
Math basic
Basic geometry
Basic math
Math
Problem
25% Success 6906 Attempts 20 Points 4s Time Limit 256MB Memory 1024 KB Max Code

You are given \(n\) points on a line. The distance between the two points is defined as follows:

\(dist(a, b) = sin(a + b) \times cos(a - b)\)

Your task is to determine the sum of the distances between all the points, where the first distance is greater than the second.

Input format

  • First line: \(n\) denoting the number of points on a line
  • Next line: \(n\) space-separated numbers that correspond to \(x_i\) denoting the points on the line

Output format

Print the number that represents the sum of the distance between all the points to exactly two decimal places.

Constraints

\(2 \le n \le 5e^5\\ -1e^9 \le x_i \le 1e^9\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
Tags:
GCD1-DArraysHashingMath Basic
Points:20
5 votes
Tags:
MathBasic MathObservationC++
Points:20
2 votes
Tags:
MathObservationBasic MathC++