'''
fast = a + (b + c)k + b
slow = a + b
2a + 2b = a + kb + kc + b
a = kb + kc - b - c + c
a = (k - 1)(b + c) + c
'''
class Solution(object):
def entryNodeOfLoop(self, head):
slow, fast = head, head
while fast and fast.next:
slow, fast = slow.next, fast.next.next
if slow == fast: # 第一次相遇
slow = head
while slow != fast:
slow, fast = slow.next, fast.next
return slow
return None