#P6307. Synthesis of the Philosopher’s Stone

    ID: 19525 Type: Default 1000ms 256MiB

Synthesis of the Philosopher’s Stone

Synthesis of the Philosopher’s Stone

In the Demon Realm, the equilateral triangle is considered the most beautiful and stable shape. Reimu sets up a triangular lattice of points forming an equilateral triangle whose side contains k points (i.e. the edge length is k-1 in terms of segments). Every point can and must host exactly one Elemental Stone.

It is known that three Elemental Stones can be synthesized into a Philosopher’s Stone if and only if they form an equilateral triangle. If Reimu randomly selects three distinct points in the lattice (and places an Elemental Stone on each), the probability that these three stones can be synthesized is denoted by \(P_k\). By convention, \(P_1=0\) (since a single point cannot form a triangle) and \(P_2=1\) (because the only triple forms an equilateral triangle).

Your task is: Given an integer \(m\), compute \[ S(m)=\sum_{k=m}^{+\infty} P_k \] where for \(k\ge2\) the probability is given by \[ P_k=\frac{\text{\# of equilateral triangles in the lattice}}{\binom{T}{3}}\quad \text{with}\quad T=\frac{k(k+1)}{2}. \] A short derivation shows that for \(k\ge2\) \[ P_k=\frac{8}{(k+2)(k^2+k-4)}. \] Note that when \(m\le1\), since \(P_1=0\) the summation effectively starts at \(k=2\).

It can be proved that the series converges. Output the value of \(S(m)\) rounded to 6 decimal places.

inputFormat

The input consists of a single integer \(m\) (\(m\ge1\)).

outputFormat

Output a single floating–point number, which is \(S(m)=\sum_{k=m}^{+\infty} P_k\), rounded to 6 decimal places.

sample

1
1.429197