Sum of the distance

3.6

22 votes
Mathematics, Math Basic, Basic Geometry, Basic Math, Math
Problem

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

dist(a,b)=sin(a+b)×cos(ab)

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 xi 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

2n5e51e9xi1e9

Sample Input
3
5 2 7
Sample Output
-0.31
Time Limit: 4
Memory Limit: 256
Source Limit:
Explanation

dist(5, 2)  + dist(5, 7) + dist(2, 7) = -0.31

 

Editor Image

?