Here is the core idea: any number can be written as a sum of powers of . For example, . To jump up steps, you could jump steps, then , then . That is only jumps instead of . This works because every number has at most bits in its binary representation.
So you need at most jumps. For up to , that is at most jumps per query.