Floyd algorithm (Turtle and Rabbit Race algorithm)
Note that this algorithm is used to determine the graph of a chain + a ring, the length of the ring or the junction of the ring with the chain, so this Floyd non-Floyd (although all is a person to think out).
(The picture is not mine)
If only the length of the ring is required, just let H and t meet, then let H run a lap, and calculate the number of steps on the line.
What if we want to figure out the junction point of the chain and the ring? First, the pointer H and T start at the same time from S, the speed one is 2, one is 1 (don't care about the details). When T goes to the junction of the chain and the ring, the distance to the right of HT is equal to the distance of St. The distance of St is x, the HT distance on the left is Y, then the length of the ring is x+y. Now let H and t go on until m intersects, so the distance to the TM on the right is obviously Y. Since the length of the ring is X+y, the TM length on the left is X. Now let the two equal-speed point one in S, one in M, while walking, will meet at T, so the junction point on the request.
Because Codevs and double 叒 Corporation on not go, so temporarily no problem.
Floyd algorithm (Turtle and Rabbit Race algorithm)