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
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
2 votes
Tags:
Maths
Points:20
Tags:
MathematicsEasyMathematicsMathamatics
Points:20
4 votes
Tags:
MathematicsOpenApprovedEasyMathamatics
Editorial
Login to unlock the editorial