AC
Algorithm:
1. use a table cycle[] to store the result from 1~1000000, and go through it to do computation
- cycle[1] = 1
- Let n be the initial value, then n will become x through n = n / 2 or n = 3 * n + 1
- if cycle[x] is not empty, then cycle[n] = cycle[x] + number of computations
Be careful:
The input will consist of a series of pairs of integers
i and
j, i may bigger than j