A particle sits on a corner of a polyhedron. Every second it jumps to one of the adjacent corners (corners connected to it by an edge), chosen uniformly at random. Compute the expected number of seconds until the particle first returns to the corner it started from.
The polyhedron is one of the following, described by its total number of faces F:
platonic F — the regular polyhedron with F faces.prism F — the k-gonal prism: two parallel regular k-gons joined by a ring of k quadrilaterals, so F = k + 2.antiprism F — the k-gonal antiprism: two parallel regular k-gons joined by a ring of 2k triangles, so F = 2k + 2.A single line with the shape and its face count: platonic F, prism F or antiprism F. The input is guaranteed to describe a valid polyhedron (F is 4, 6, 8, 12 or 20 for platonic; F >= 5 for prism; F >= 8 and even for antiprism).
Output the expected return time with absolute or relative error at most 1e-6.
F <= 10^9
This is a standard problem: a submission scores full points if it produces the correct output for every test case, and zero otherwise.
Numeric answers are accepted if they are within an absolute tolerance of 1e-06 or a relative tolerance of 1e-06 of the expected value.
platonic 4
4.000000000
prism 5
6.000000000