Digital triangle problem
Http://sotong.sec.samsung.net/sotong/practice/practiceProbView.do?practiceProbId=AUkG9ZnV1GXVldGG
Consider the position (I,J) as a state, and then define the indicator function D (i,j) of the State (I,J): The maximum that can be obtained when starting from the position (I,J).
Recursive calculation:
int i,j;
Boundary Value Processing
for (j=1;j<=n;j++)
RESULT[N][J] = Data[n][j];
From the bottom up dynamic plan, save the leaf node to the maximum value of the current node
for (i=n-1; i>=1;i--)
for (j = 1; j<=i; j + +)
RESULT[I][J] =data[i][j]+max (result[i+1][j],result[i+1][j+1])
Memory Search:
memset (result,-1,sizeof (Result))
int solve (int i, int j)
{
Judge Result[i][j] >= 0 To determine if the node has been computed
if (Result[i][j] >= 0)
return RESULT[I][J];
return result[i][j] = Data[i][j] + (I==n?0:max (Solve (I+1,J), Solve (i+1,j+1)));
}
Sotong Similar topics:
Http://sotong.sec.samsung.net/sotong/practice/practiceProbView.do?practiceProbId=AUWlrlNFQzfVldEJ
Dynamic Planning (DP)
Coin problem:
There are n kinds of coins, denominations of V1, V2, V3,......, Vn, each with an unlimited number of coins, so that the sum of the par is exactly s, the maximum and minimum value of the output coins. -the longest and shortest path to the fixed end
Directed acyclic graph for dag (Directed acyclic graph)
BFS
Http://sotong.sec.samsung.net/sotong/practice/practiceProbView.do?practiceProbId=AUh3hAH1BFHVldFk
All-Purpose Templates:
Recommended URL:
http://poj.org/
Http://www.cnblogs.com/qiufeihai/archive/2012/09/11/2680840.html
Dynamic Planning Learning