Under construction

Still being built. Things may change

Bucket Game

Interview

Time limit2sMemory limit1024 MB

Summary
Water poured into bucket 1 splits equally among each bucket's outgoing hoses in a DAG. Find the largest amount any single bucket holds.
Level

Easy3 of 10

Topics
Graph, Topological sort, Dynamic programming
Solved
No attempts yet

Problem

Chanwoo agreed to play a simple game with participants of the Cheonha Jeil Coding Contest. The game is called 'Bucket Game'. Pour 100100 units of water into the top bucket and let it flow. The winner picks the bucket that ends up holding the most water. Chanwoo cannot see how the buckets are connected until he picks one, but he already knows how they are connected. Find how much water is in the bucket Chanwoo must pick to win.

Bucket 11 is always at the top. When a bucket holding 11 unit of water has K>0K>0 outgoing hoses, water flows through each hose at 1/K1/K per hose until the bucket is empty. A smaller bucket number means a higher position, so water always flows from a smaller-numbered bucket to a larger-numbered one.

Input

The first line has the number of buckets NN and the number of hoses MM, separated by a space. (1≤N≤501 \le N \le 50, 0≤M≤1000 \le M \le 100)

Each of the next MM lines has two integers vv and ww, separated by a space. (1≤v<w≤N1 \le v < w \le N) This means a hose carries water from bucket vv to bucket ww.

No hose is given more than once. That is, every pair (v,w)(v, w) in the input is different.

Output

Pour 100100 units of water into bucket 11 and let it flow. Print the largest amount of water held by any single bucket. The answer is accepted if its absolute or relative error from the true answer is at most 10−610^{-6}.

Hint

Absolute error is the difference between the true answer and the printed value. Relative error is the absolute error divided by the true answer. If the true answer is aa and the printed value is bb, the absolute error is ∣a−b∣|a - b| and the relative error is ∣a−b∣a\frac{|a - b|}{a}.

Examples2

  1. Example 1

    Input
    5 4
    1 2
    1 3
    2 4
    2 5
    
    Expected output
    50.0
    
  2. Example 2

    Input
    9 7
    1 2
    1 3
    2 4
    6 8
    3 5
    6 9
    3 6
    
    Expected output
    50.0