2009年12月20日 星期日

ACM 101

AC

watch out the variable name

watch out the boundary case

an easy simulation problem

2009年12月16日 星期三

ACM 100

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