#P8657. Expected Travel Time in Flea Country
Expected Travel Time in Flea Country
Expected Travel Time in Flea Country
In Flea Country, every city is turned into a tourist attraction. Fleas wish to travel to different cities but find themselves traveling slowly until the advent of a fast train system. In this system, a railway is built between every pair of cities. However, the train driver cannot operate the switchbacks; therefore, once a train arrives at a city, it will not go back to the city it came from, and instead it will choose one of the other connected cities uniformly at random.
Each train ride between two cities takes exactly 1 unit of time.
For a flea starting from a city s, the journey begins by taking a train from s to one of the other cities. After that, if the train is in city i and it came from city j (with j not necessarily equal to s), then the train will choose its next destination from all cities except j with equal probability. The journey continues until the train returns to the starting city s. The Flea King wants to know the expected travel time (in units of time) for a flea starting from each city.
It turns out that in this completely connected network with the no-backtracking restriction, the expected travel time for a flea starting from any city is given by \(n\) (i.e. the number of cities). Your task is to compute and output these expected travel times for every city.
Note: The answer is theoretically derived to be \(n\) for every starting city.
inputFormat
The first and only line of input contains a single integer \(n\) (where \(n \ge 3\)) representing the number of cities in Flea Country.
outputFormat
Output a single line containing \(n\) space-separated integers. Each integer should be the expected travel time for a flea starting from that city. According to the derived formula, each value is \(n\).
sample
3
3 3 3