#include<bits/stdc++.h>
using namespace std;
double kai=10000,eps=1,jiang=0.92,fw;//fw 记得赋值
mt19937 rd(time(0));
#define bu t*(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)>gl) x=o1;}}cout<<ans;return 0;
}
模拟退火不能无脑退火,要结合性质。
- 构造好初始解
- 猜想答案特性
- 选择更牛的随机下一步的方式
- 优化 calc
- 调参。
我才发现我是唐人,答案数组最好开 double,不开的话一定要记得在 \(△d/t\) 时加上 1.0*
不然你就会完了!