Triangle#1842

Triangle

6 Sekunden
256 Megabyte
Sehr leicht

On the plane, there are points (3 \leq N). Three of these points are chosen at random and connected by segments. You are required to determine the expected value of the perimeter of the resulting triangle, given that each set of three points can be chosen with equal probability, and the resulting triangle may be degenerate.

Eingabe

The first line contains two integers and (1 \leq H, W \leq 700). This is followed by lines, each containing characters. The -th character of the -th line is '1' if there is a point at the coordinates ; otherwise, it is '0'. It is guaranteed that there are at least three points in the input.

Ausgabe

Output a single number — the expected value of the perimeter of the triangle. The answer must differ from the correct answer by no more than 10^{-6}.

Beispiele

Beispiel 1

Loading
Loading