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. 分页查询关键代码 多条件查询关键代码 删除选中商品关键代码 修改要先回显再修改 修改要先回显再修改 同一业务集中使用同一servlet的方法

    分页查询关键代码: 通过servlet转发回来的各种信息进行分页的设计(转发回的信息有 分页查询的List集合 查询的页码 查询的条数 查询的数据库总条数 查询的总页码) 从开始时循环10次出现十个数 ...

  2. React dangerouslySetInnerHTML - 将HTML字符串解析为html样式显示

    <div dangerouslySetInnerHTML={{ __html: curriculumDesc }}></div>

  3. layer 的功能

    1.layer.alert() layer.alert('',{ title: "<div style='color:red;margin-left:20px;font-size:20 ...

  4. datatable行内内容太长,有时不自动换行解决方法

    加一个css属性即可 style = "word-wrap:break-word;" js代码: "render": function (data, type, ...

  5. Python全栈day 05

    Python全栈day 05 一.数据类型补充 1. int py2和py3的2种区别 py2有int和long,int的取值范围为-2^31~2^31-1,超出范围自动转为long,长整型. py2 ...

  6. UIView控件 概况

    一.UIKit结构图 ------------------------------------------------------------------------------- @interfac ...

  7. Skyscrapers Covered in Solar Pancels【太阳能电池板覆盖的摩天大楼】

    Skyscrapers Covered in Solar Panels An office tower on Miller Stree in Manchester is completely cove ...

  8. C++基础 静态成员

    静态成员是类的所有 对象共有的变量,在编译 阶段就必须分配空间. 需要注意: (1)静态成员变量的定义和使用 class Test{ static int a; }; ; void main() {} ...

  9. Drazil and Tiles CodeForces - 516B (类拓扑)

    Drazil created a following problem about putting 1 × 2 tiles into an n × m grid: "There is a gr ...

  10. [BZOJ3172 ][Tjoi2013]单词(AC自动机)

    Description 不稳定的传送门 某人读论文,一篇论文是由许多单词组成.但他发现一个单词会在论文中出现很多次,现在想知道每个单词分别在论文中出现多少次.单词个数<=200,单词总长度< ...