Enigmatic Travel
Time limit1sMemory limit128 MB
For each complete graph size L, compute the average cost of a random walk, a random simple path, and a random simple cycle.
- Level
Medium7 of 10
- Topics
- Combinatorics, Math, Dynamic programming
- Solved
- No attempts yet
Problem
Suhan and Laina live in a city that has locations. Every pair of locations lies the same distance apart, and each pair is joined by exactly one two-way road — so the road map is a complete graph on vertices. Driving along any single road costs exactly universal joule.
They love wandering the city together and keep every trip secret: no one knows where they start, where they finish, or which roads they take. A trip may begin at any location and end at any location — the end may be the same as the start — and it may follow any sequence of roads they like. (For instance, when the trip is a simple cycle, the start and the end coincide.)
Given the number of locations , compute the expected (average) cost of a single trip under three different assumptions about what kind of trip it is. You may assume the cost of a trip never exceeds .
Input
The input consists of several lines. Each line holds a single integer (), the number of locations. The input ends with a line containing , which must not be processed.
Output
For every input line, print one line with three floating-point numbers , , , each rounded to exactly four digits after the decimal point:
- is the expected cost of an arbitrary trip (any sequence of roads, i.e. a walk).
- is the expected cost of a trip guaranteed to be a simple path (no location is visited twice).
- is the expected cost of a trip guaranteed to be a simple cycle (it returns to the start and repeats no other location).
Every cost is measured in universal joules.