eolymp
bolt
Try our new interface for solving problems
Problems

Hash-table

Hash-table

Alex learned about a new data structure: a hash table with open addressing. Hash table with open addressing consists of N cells numbered from 1 to N. Each of them may be empty, or storing a value. When you insert a new value, it calculates the hash --- random number between 1 to N (let’s call it h) --- after which, if the cell under number h is empty, the value is written into it. Otherwise, if the cell h + 1 is empty, the value is written into it, and otherwise it checks h + 2, h + 3 and so on. If the search has reached N-th cell, and it is not empty too, the search continues with the cell number 1. Thus, if there are an empty place somewhere, the value anyway will be added. For example, if the value is equal to the hash h, the cell turned recorded h + 2 then we can assume, that there were two collisions occurred. Collisions slow down the hash table, so Alex decided to find out how many collisions will be in average, if in a empty hash table insert M different values. And calculate, as always, to you. \textbf{Limit} 1 \textit{≤ N ≤ }100 0 \textit{≤ M ≤ N} \InputFile The single line contains 2 integers: N and M. \OutputFile You should print a single number --- an average number of collisions. Print the answer with absolute or relative error of less than 10 ^7.
Time limit 1 second
Memory limit 256 MiB
Input example #1
5 1
Output example #1
0.000000000
Author Евгений Капун
Source Зимняя школа по программированию 2014, Харьков