Certain number of cars are passing a single lane road. Speeds of all cars vary. It is easy to see, that depending on the speeds of the cars various groups will be formed.
Being a single lane road passing/overtaking is not allowed. Given speeds of cars, calculate how many groups can be formed if all possible permutations are taken into account. Refer example1 for better understanding.
Print number of groups divided by the number of permutations.
Constraints
0 <= N < 10 ^ 5
0 <= speed of individual vehicle < 10 ^ 9
Input
First line contains an integer N, which denotes the number of vehicles
Second line contains N space separated integers which denotes the speed of individual vehicle.
Output
Print number of groups divided by the number of permutations rounded upto 6 decimal places.
Time Limit
1
Examples
Example 1
Input
3
10 20 30
Output
1.833333
Explanation:
So all possible permutations are:
{10 20 30}
{10 30 20}
{20} {10 30}
{20 30} {10}
{30} {10 20}
{30 20} {10}
So here there are total 6 permutations, and total number of groups are 11.
So, output is 11/6 = 1.833333
Example 2
Input
4
56 78 13 92
Output
2.083333
Explanation:
So here there are total 24 permutations,
For example:
{56 78 13 92}
{92} {13 78 56}
{56} {13 92 78}
{78 92} {13 56}
.
.
So on and so forth. The total number of groups are 50.
So, the output is 50/24 = 2.083333
Answers
Answered by
1
yeh kya hai itna bada question
Answered by
2
Answer:
n = int(input())
s = list(map(int, input().split()))
g = 0
for i in range(1, n+1):
g = g + 1/i
print("{:.6f}".format(g), end="")
Explanation:
The logic of the question is based on Geometric progression(GP).You have just need to find summation of GP like if given 3 speeds u need to do is
1+1/2+1/3 and for 4 speeds 1+1/2+1/3+1/4 and so on. We dont even require what are the speeds of the vehicles we just require the number of different speed cars.
Similar questions
Science,
4 months ago
English,
4 months ago
Math,
9 months ago
Physics,
9 months ago
CBSE BOARD X,
1 year ago