![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
模拟退火
crazy morning
去西之西处,驾驭长风
展开
-
P2210 Haywire
题目 题目 思路 先随便分在2个组,接下来模拟退火计算。 code: #include<cctype> #include<cerrno> #include<cfloat> #include<ciso646> #include<climits> #include<clocale> #include<cmath> #include<csetjmp> #include<csignal> #include&l原创 2021-05-19 20:56:07 · 70 阅读 · 0 评论 -
UVA10228 A Star not a Tree?
题目 题目 思路 可以使用模拟退火解决。 模拟退火是一个基于物理随机化的算法,有一个类比: 随着时间流逝,高温液体慢慢冷却下来,原子交换顺序慢慢变得缓慢。 我们模仿原子的交换(随机化处理)以更新答案。 若当前答案不如新答案优,则更新,同时以后的退火都以现答案为标准。 否则,一定概率让以后的退火都以现答案为标准,不更新答案。 代码实现: if (del<0) ans=u,ssx=sx,ssy=sy,sx=wj2,sy=lyw2; else if (exp(-del/time)*RAND_MAX&原创 2021-05-18 21:22:51 · 63 阅读 · 0 评论