蠻簡單的一題

不過蠻有趣的

robertanders 發表在 痞客邦 留言(0) 人氣()

先求SCC

再來你要求是不是有一個group

robertanders 發表在 痞客邦 留言(0) 人氣()

DFS搜尋

State只有3^(N-1)種

robertanders 發表在 痞客邦 留言(0) 人氣()

推導出公式

L(2a + L - 1)/2 = N

robertanders 發表在 痞客邦 留言(0) 人氣()

Idea #1: Heuristic Pruning

The easiest and most common use for heuristic functions is to prune the search space. Assume the problem is to find the solution with the minimum total cost. With an admissible heuristic function, if the cost of the current solution thus far is A, and the heuristic function returns B, then the best possible solution which is a child of the current solution is A+B. If the a solution has been found with cost C, where C < A+B, there is no reason to continue searching for a solution from this state.

This is simple to code and debug (assuming one starts with a working, but slow, program, which is how this should be used) and can yield immense returns in terms of run-time. It is especially helpful with depth-first search with iterative deepening.

robertanders 發表在 痞客邦 留言(0) 人氣()

先做好Precalculation

時間複雜度是O(maxN)

robertanders 發表在 痞客邦 留言(0) 人氣()

判斷有點多

以下說明有哪些不合法情況

robertanders 發表在 痞客邦 留言(0) 人氣()

很簡單的一題

如果你用其他方法做(應該都比較麻煩)

robertanders 發表在 痞客邦 留言(0) 人氣()

先找出1 - 10000的質數

再來就是求Consecutive的Sum

robertanders 發表在 痞客邦 留言(0) 人氣()

先預算好所有答案

因為他規定number不能recurring

robertanders 發表在 痞客邦 留言(0) 人氣()