顯示具有 ACM 標籤的文章。 顯示所有文章
顯示具有 ACM 標籤的文章。 顯示所有文章

2010年7月1日 星期四

ACM 103

alright

It's a greedy algorithm problem

Use an adjacency list to save the graph,
then find every vertex's successor which has most successors.

2010年6月26日 星期六

ACM 102

AC

EZ

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