Driving on a Tree

AtCoder
IDs8pc_4_d
Time1000ms
Memory256MB
Difficulty
There is an undirected connected graph with $N$ vertices and $N-1$ edges. The $i$\-th edge connects $u_i$ and $v_i$. E869120 the coder moves in the graph as follows: * He move to adjacent vertex, but he can't a visit vertex two or more times. * He ends move when there is no way to move. * Otherwise, he moves randomly. (equal probability) If he has $p$ way to move this turn, he choose each vertex with $1/p$ probability. ![image](https://atcoder.jp/img/s8pc-4/5973dad11843e9098d9225dd431c9084.png) Calculate the expected value of the number of turns, when E869120 starts from vertex $i$, for all $i (1 ≤ i ≤ N)$. ## Input The input is given from standard input in the following format. $N$ $u_1$ $v_1$ $u_2$ $v_2$ : $u_{N-1}$ $v_{N-1}$ [samples]
API Response (JSON)
{
  "problem": {
    "name": "Driving on a Tree",
    "description": {
      "content": "There is an undirected connected graph with $N$ vertices and $N-1$ edges. The $i$\\-th edge connects $u_i$ and $v_i$.      E869120 the coder moves in the graph as follows:   *   He move to adjacent ve",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "s8pc_4_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There is an undirected connected graph with $N$ vertices and $N-1$ edges. The $i$\\-th edge connects $u_i$ and $v_i$.  \n  \nE869120 the coder moves in the graph as follows:  \n\n*   He move to adjacent ve...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments