题意

题目链接

求 $F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)$的最小值

Sol

强上模拟退火,注意eps要开大!

/*
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
const int MAXN = 1e6 + ;
const double eps = 1e-, Dlt = 0.98;
int T;
double Y, Best;
double F(double x) {
return * x * x * x * x * x * x * x + * x * x * x * x * x * x + * x * x * x + * x * x - Y * x;
}
double getrand(double T) {
return T * ((rand() << ) - RAND_MAX);
}
double solve(int id) {
double x = id, now = F(x);
Best = min(Best, now);
for(double T = ; T > eps; T *= Dlt) {
double wx = x + getrand(T), wv = F(wx);
if(wx > eps && (wx - <= eps)) {
if(wv < Best) x = wx, Best = wv, now = wv;
if(wv < now || ((exp((wv - now) / T)) * RAND_MAX < rand())) now = wv, x = wx;
}
}
}
int main() {
srand((unsigned)time(NULL));
scanf("%d", &T);
while(T--) { Best = 1e20;
scanf("%lf", &Y);
int times = ;
while(times--) solve(times);
printf("%.4lf\n", Best);
}
return ;
}
/*
3
100
200
1000000000
*/

HDU 2899Strange fuction(模拟退火)的更多相关文章

  1. hdu 2899 Strange fuction——模拟退火

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=2899 还可三分.不过只写了模拟退火. #include<iostream> #include& ...

  2. hdu 2899 Strange fuction —— 模拟退火

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=2899 模拟退火: 怎么也过不了,竟然是忘了写 lst = tmp ... 还是挺容易A的. 代码如下: # ...

  3. hdu 2899 Strange fuction 模拟退火

    求  F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)的最小值 模拟退火,每次根据温度随机下个状态,再根据温度转移 #include& ...

  4. HDU 5017 Ellipsoid 模拟退火第一题

    为了补这题,特意学了下模拟退火算法,感觉算法本身不是很难,就是可能降温系数,步长等参数不好设置. 具体学习可以参见: http://www.cnblogs.com/heaad/archive/2010 ...

  5. Groundhog Build Home - HDU - 3932(模拟退火)

    题意 给定一个矩形内的\(n\)个点,在矩形中找一个点,离其他点的最大距离最小. 题解 模拟退火. 这个题需要\(x\)和\(y\)坐标随机动的时候多随机几次.否则就WA了.另外由于随机多次,如果温度 ...

  6. The Moving Points - HDU - 4717 (模拟退火)

    题意 二维空间中有\(n\)个运动的点,每个点有一个初始坐标和速度向量.求出一个时间\(T\),使得此时任意两点之间的最大距离最小.输出\(T\)和最大距离. 题解 模拟退火. 这个题告诉了我,初始步 ...

  7. hdu Strange fuction

    本题是一道二分题,但是要利用导数来求最小值.对原函数进行求导,得到的导函数为f(x)=42*pow(x,6)+48*pow(x,5)+21*pow(x,2)+10*x-y;因为0<=x<= ...

  8. HDU - 5017 Ellipsoid(模拟退火法)

    Problem Description Given a 3-dimension ellipsoid(椭球面) your task is to find the minimal distance bet ...

  9. hdu 2899 Strange fuction

    http://acm.hdu.edu.cn/showproblem.php?pid=2899 Strange fuction Time Limit: 2000/1000 MS (Java/Others ...

随机推荐

  1. spring cloud之简单介绍

    以下是来自官方的一篇简单介绍: spring Cloud provides tools for developers to quickly build some of the common patte ...

  2. Nuget-QRCode:jquery-qrcode

    ylbtech-Nuget-QRCode:jquery-qrcode 1.返回顶部 1. <!DOCTYPE html> <html> <head> <tit ...

  3. SpringMVC前置控制器SimpleUrlHandlerMapping配置

    1. <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5&qu ...

  4. glib 库 hash table 使用

    glib库提供了 hashtable 的实现 1. 常用函数: 创建一个 GHashTable 函数: hash_func 是创建value的key值的函数,key_equal_func 是比较两个k ...

  5. 廖雪峰的java教程

    F:\教程\0-免费下载-廖雪峰 公司电脑地址: G:\学习中\廖雪峰的java教程 廖雪峰java课程地址: https://www.feiyangedu.com/category/JavaSE 0 ...

  6. 将Opencv java中的Mat通过jni传递到C++中的方法

    public native void FindFeatures(long matAddrGr, long matAddrRgba); ... mRgba = new Mat(height, width ...

  7. Unity手游之路自动寻路Navmesh之高级主题

    http://blog.csdn.net/janeky/article/details/17492531 之前我们一起学习了如何使用Navmesh组件来实现最基本的角色自动寻路.今天我们再继续深入探索 ...

  8. 【转】oracle的分析函数over

    源地址:http://www.cnblogs.com/sumsen/archive/2012/05/30/2525800.html

  9. ajax对象。同步与异步及ajax发送请求

    ajax对象的属性.方法 属性 readyState: Ajax状态码 * 0:表示对象已建立,但未初始化,只是 new 成功获取了对象,但是未调用open方法 1:表示对象已初始化,但未发送,调用了 ...

  10. 更新常用的js工具函数

    在手机调试时打印代码<script src="https://cdn.bootcss.com/vConsole/3.3.0/vconsole.min.js"></ ...