请问这是模拟退火吗?
  • 板块灌水区
  • 楼主OIbishop
  • 当前回复10
  • 已保存回复10
  • 发布时间2022/10/12 21:41
  • 上次更新2023/10/27 07:44:56
查看原帖
请问这是模拟退火吗?
748239
OIbishop楼主2022/10/12 21:41
#include <bits/stdc++.h>
using namespace std;
int a[10005] , ans  , n;
bool f[10005];
inline void qwe ()
{
	double t = 100000;
	while (t > 0.00000001)
	{
		int i = rand () % n + 1;
		if (f[i]) continue;
		if (a[i] > ans) ans = a[i] , f[i] = 1;
		t *= 0.985;
	}
}
signed main ()
{
	srand (time (0));
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	qwe ();
	cout << ans;
	return 0;
}

序列中求最大值

另 : 有什么好的网页学模拟退火?找了几个,看不懂

2022/10/12 21:41
加载中...