Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Yoda and Luke Skywalker are peacefully sitting on an infinite tree that I don't know the name of. The root of the tree has the ID 1, and each node has N children with IDs X*N, X*N+1, X*N+2, ..., X*N+N-1, where X is the ID of the parent. This is what the first 3 depths of a tree with N=3 look like:(image from statement)
- Yoda was suddenly attacked by villains and Luke wants to save him. Help Luke and tell him the distance between him and Yoda!
- Input: N, the ID of the node Yoda is on, the ID of the node Luke is on.
- Output: The distance.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement