加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
填空.java 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
吴上文 提交于 2022-12-06 15:13 . pta
/*
5-1棋盘覆盖问题(分治法)
size==1
dr < tr + s && dc < tc + s
ChessBoard(tr,tc,dr,dc,s)
board[tr+s-1][tc+s-1]=t
ChessBoard(tr,tc,tr+s-1,tc+s-1,s)
dr < tr + s && dc >= tc + s
ChessBoard(tr,tc+s,dr,dc,s)
board[tr+s-1][tc+s]=t
ChessBoard(tr,tc+s,tr+s-1,tc+s,s)
dr >= tr + s && dc < tc + s
ChessBoard(tr+s,tc,dr,dc,s)
board[tr+s][tc+s-1]=t
ChessBoard(tr+s,tc,tr+s,tc+s-1,s)
dr>=tr+s && dc>=tc+s
ChessBoard(tr+s,tc+s,dr,dc,s)
board[tr+s][tc+s]=t
ChessBoard(tr+s,tc+s,tr+s,tc+s,s)
5-2快速排序(分治法)
low<high
low < high && L.r[high] >= pivotkey
low < high && L.r[low] <= pivotkey
Partition(L,low,high)
QSort(L,low,pivotloc-1)
QSort(L,pivotloc+1,high)
5-3归并排序(递归法)
T[low]=R[low]
MSort(R,S,low,mid)
MSort(R,S,mid+1,high)
Merge(S,T,low,mid,high)
5-4部分背包问题(贪心法)
A[i].w<=weight
weight-=A[i].w
i++
weight/A[i].w
5-5最小生成树(普里姆算法)
min > closedge[i].lowcost && closedge[i].lowcost != 0
u
G.arcs[k][j]
0
Min(G)
0
G.vexs[k]
G.arcs[k][j]
5-6求解活动安排问题(贪心法)
A[i].b>=preend
flag[i]=true
preend=A[i].e
5-7多段图问题(动态规划法)
arc[i][j] + cost[i] < cost[j]
cost[j] = arc[i][j] + cost[i]
path[j]
cost[n-1]
5-8最短路径(弗洛伊德算法)
G.arcs[i][j]
Path[i][j]=i
D[i][k] + D[k][j]
D[i][k]+D[k][j]
Path[k][j]
5-9求解图的m着色问题(回溯法)
a[i][j]==1 && x[i]==x[j]
count++
Same(i)
x[i]=0
5-10 0/1背包问题(回溯法)
tw==W && tv>maxv
j=1;j<=n;j++
tw+w[i]<=W
i+1,tw+w[i],tv+v[i],rw-w[i],op
tw+rw>W
i+1,tw,tv,rw-w[i],op
5-11 求解n皇后问题(递归回溯法)
return false
return true
place(i,j)
queen(i+1,n)
*/
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化