Strange fuction

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2278    Accepted Submission(s): 1697

Problem Description
Now, here is a fuction:
  F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)
Can you find the minimum value when x is between 0 and 100.
 
Input
The first line of the input contains an integer T(1<=T<=100) which means the number of test cases. Then T lines follow, each line has only one real numbers Y.(0 < Y <1e10)
 
Output
Just the minimum value (accurate up to 4 decimal places),when x is between 0 and 100.
 
Sample Input
2
100
200
 
Sample Output
-74.4291
-178.8534
 
Author
Redow
 
Recommend
lcy   |   We have carefully selected several similar problems for you:  2289 2298 2141 3400 1969 
 
 //0MS    224K    590 B    G++
/* 题意:
给出一关系式:
F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)
和y的值,求x在范围(0,100)内时F(x)能取得的最小值 二分法:
很容易可以看出函数F(x)在(0,100)内是先减后增的,故用二分法求其倒数的零值点,然后用零值
再代入原式即可求出最值 */
#include<stdio.h>
#define e 1e-7
double fac(double a,double b)
{
return *a*a*a*a*a*a*a+*a*a*a*a*a*a+*a*a*a+*a*a-b*a;
}
double fac0(double a,double b)
{
return *a*a*a*a*a*a+*a*a*a*a*a+*a*a+*a-b;
}
int main(void)
{
int t;
double n;
scanf("%d",&t);
while(t--)
{
scanf("%lf",&n);
double l=;
double r=;
while(r-l>e){
double mid=(l+r)/;
if(fac0(mid,n)>) r=mid;
else l=mid;
}
printf("%.4lf\n",fac(r,n));
}
return ;
}

hdu 2899 Strange fuction (二分法)的更多相关文章

  1. hdu 2899 Strange fuction

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

  2. ACM : HDU 2899 Strange fuction 解题报告 -二分、三分

    Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...

  3. hdu 2899 Strange fuction (二分)

    题目链接:http://acm.hdu.edu.cn/showproblem.pihp?pid=2899 题目大意:找出满足F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x ( ...

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

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

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

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

  6. HDU 2899 Strange fuction 【三分】

    三分可以用来求单峰函数的极值. 首先对一个函数要使用三分时,必须确保该函数在范围内是单峰的. 又因为凸函数必定是单峰的. 证明一个函数是凸函数的方法: 所以就变成证明该函数的一阶导数是否单调递增,或者 ...

  7. hdu 2899 Strange fuction 模拟退火

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

  8. HDU.2899.Strange fuction(牛顿迭代)

    题目链接 \(Description\) 求函数\(F(x)=6\times x^7+8\times x^6+7\times x^3+5\times x^2-y\times x\)在\(x\in \l ...

  9. HDU 2899 Strange fuction [二分]

    1.题意:给一个函数F(X)的表达式,求其最值,自变量定义域为0到100 2.分析:写出题面函数的导函数的表达式,二分求导函数的零点,对应的就是极值点 3.代码: # include <iost ...

随机推荐

  1. ubuntu安装jdk6

    我的ubuntu版本是12.04的64位的.由于ubuntu官方没有更新最新版的jdk6,所以我们只能主动去oracle公司网站去下载.网站地址:http://www.oracle.com/techn ...

  2. BZOJ2752: [HAOI2012]高速公路(road)(线段树 期望)

    Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 1820  Solved: 736[Submit][Status][Discuss] Descripti ...

  3. MySQL 5.7基于GTID的主从复制环境搭建(一主一从)

      Preface       As wel all know,replication base on GTID with row format of binary log is comprehens ...

  4. 交换机基础配置之stp生成树实验

    实验的要求是以上面的拓扑图为例,查看当前根桥的所在并把三成交换机switch1指定为根桥 我们可以用show spanning-tree来查看stp的信息 输入后会显示两部分 上面一部分为当前交换机自 ...

  5. Git版本控制使用方法入门教程

    1. 概述 对于软件版本管理工具,酷讯决定摒弃CVS而转向Git了. 为什么要选择Git? 你真正学会使用Git时, 你就会觉得这个问题的回答是非常自然的.然而当真正需要用文字来回答时,却觉得文字好像 ...

  6. MySQL的备份

    MySQL的备份 开启MySQL的log_bin 执行查看mysql的log_bin状态 > show variables like 'log_bin%'; +----------------- ...

  7. C++基础 new和delete

    1.new delete 的使用 (1)基本数据类型 ); delete p; int *p = (int *)malloc(sizeof(int)); *p = ;free(p); (2)数组 ]; ...

  8. SpringMVC文件上传——bean的配置【org.springframework.web.multipart.commons.CommonsMultipartResolver】

    一.简介 Spring MVC支持一个通用的多路上传解析器CommonsMultipartResolver,在Spring的配置文件中对CommonsMultipartResolver Bean进行配 ...

  9. Linux与BSD不同

    https://linux.cn/article-3186-1.html https://www.howtogeek.com/190773/htg-explains-whats-the-differe ...

  10. 十二、mysql之视图,触发器,事务等

    一.视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,可以将该结果集当做表来使用. 使用视图我们可以把查询过程中的 ...