题意

题目链接

求 $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. 误删除$ORACLE_HOME/dbs下的参数文件、密码文件,如何快速重建

    [oracle@11g dbs]$ pwd/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs[oracle@11g dbs]$ lltotal 24 ...

  2. ogg日常运维命令

    1.查看历史记录.快捷执行历史中的一条命令 GGSCI (11g) 32> h 23: view param exta24: info all25: lag exta.... GGSCI (11 ...

  3. Eclipse插件:tomcatPluginV33.zip 安装

    一.下载 地址:http://www.eclipsetotale.com/tomcatPlugin.html 二.安装 1.解压tomcatPluginV33.zip到Eclipse的\feature ...

  4. Java 打包成exe安装包

    1.在eclipse中导出Runnable JAR file 2.选择主函数所在的类和输出位置后finish: 3.这里选择的打包工具是exe4j,在网上找序列号注册一下,否则在打完后在exe运行时, ...

  5. 1.14不使用回车键来读取n个字符

    read是一个重要的bash命令,它用于从键盘或标准输入中读取文本.可以使用read以交互的形式读取来自用户的输入,不过read能做的远不止这些.很多编程语言的输入库都是从键盘读取输入,且只有回车键按 ...

  6. JAVA企业级开发-BOM&DOM(03)

    一.BOM对象介绍 BOM对象:Browser Object Model 浏览器对象模型.把整个浏览器当做一个对象来处理. 一个浏览器对象中又包含了其他的对象. 重点介绍:window.history ...

  7. css正方形盒子 自适应

      <!DOCTYPE html>   <html lang="en">   <head>   <meta charset="U ...

  8. Fiddler设置断点修改Request和Response【转】

    Fiddler设置断点修改Request和Response 设置断点的两种方式:工具栏和命令 1.工具栏:Rules -> Automatic Breakpoints(automatic [ɔː ...

  9. axios发送两次请求原因及解决方法

    axios发送两次请求原因及解决方法 最近Vue项目中使用axios组件,在页面交互中发现axios会发送两次请求,一种请求方式为OPTIONS,另外一种为自己设置的. 如图: 什么是CORS通信? ...

  10. pgfincore外部OS缓存安装

    su - root cd /opt/soft_baktar -zxvf pgfincore-1.0.gz cd pgfincore-b2b53deexport PATH=/opt/pgsql963/b ...