Visual 開發 希望對你們有幫助
public static int Rom(int n, int m)//雙寄或雙偶
{
int count = 0 //第一排Y坐標上要幾個
if (n < m)
{
for (int i = 1 i <= n i = i + 2)
{
count++
}
}
else
{
for (int j = 1 j <= m j = j + 2)
{
count++
}
}
return count
}
很經典的一個算法。大家做工程和通信用的著。遺傳算法(Genetic Algorithm)是模擬達爾文的遺傳選擇和自然淘汰的生物進化過程的計算模型,是一種通過模擬自然進化過程搜索最優解的方法,它是有美國Michigan大學J.Holland教授于1975年首先提出來的,并出版了頗有影響的專著《Adaptation in Natural and Artificial Systems》,GA這個名稱才逐漸為人所知,J.Holland教授所提出的GA通常為簡單遺傳算法(SGA)。
Instead of finding the longest common
subsequence, let us try to determine the
length of the LCS.
Then tracking back to find the LCS.
Consider a1a2…am and b1b2…bn.
Case 1: am=bn. The LCS must contain am,
we have to find the LCS of a1a2…am-1 and
b1b2…bn-1.
Case 2: am≠bn. Wehave to find the LCS of
a1a2…am-1 and b1b2…bn, and a1a2…am and
b b b
b1b2…bn-1
Let A = a1 a2 … am and B = b1 b2 … bn
Let Li j denote the length of the longest i,g g
common subsequence of a1 a2 … ai and b1 b2
… bj.
Li,j = Li-1,j-1 + 1 if ai=bj
max{ L L } a≠b i-1,j, i,j-1 if ai≠j
L0,0 = L0,j = Li,0 = 0 for 1≤i≤m, 1≤j≤n.