ppip @ 2022-05-16 21:12:42
模拟退火板子:
void sa()
{
for (double T=Begin;T>End;T*=Rate)
{
int x=rand()%cnt1+1;
int y=rand()%cnt2+1;
swap(s1[x],s2[y]);
ll res=calc();
if (res<ans) ans=res;
else if (exp((ans-res)/T)<(double)rand()/RAND_MAX) swap(s1[x],s2[y]);
}
}
其中最后一行有的写小于号有的写大于号,请问到底哪种写法是正确的呢?
求解释 qwq
by EastPorridge @ 2022-05-16 21:17:07
看情况的罢,题目具体描述的劣解情况不同符号也不同的
by ppip @ 2022-05-16 21:26:35
@EastPorridge 那如何「看情况」呢
by EastPorridge @ 2022-05-16 21:29:10
针对