跳到正文

个人记录

正宗!就是这个味儿!模拟退火(๑•̀ㅂ•́)و✧

a1a2a3a4a5约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年2月17日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
using namespace std;
double kai=10000,eps=1,jiang=0.92,fw;//fw 记得赋值
mt19937 rd(time(0));
#define bu t/kai*(rd()%(2*(int)fw)*1.0-fw)
#define gl 1.0*rand()/RAND_MAX
int ans,sx;//题目要求时开 double
int cha(int x)
{



	return ans;
}
signed main()
{
	srand(20090918);
	sx=;//
	fw=;//
	ans=cha(sx);
	while (1.0*clock()/CLOCKS_PER_SEC<0.9)
	{
		int nw=ans,x=sx;
		for(double t=kai;t>eps;t*=jiang)
		{
			int o1=x+bu,k;
			while(o1∈[?,?]) o1=x+bu;
			k=cha(o1);
			if(k>ans) ans=k,sx=o1;
			if(k>nw||exp((k-nw)/(t/kai))>gl) x=o1;
		}
	}
	cout<<ans;
	return 0;
}
原文