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
题意:给你一个y值,x的范围是1~100;求所给方程的最小值;
解题思路:最小值就导数为零的点;
感悟:本来想用二分做,但是。。。。。。不会,后来想起来用导数做;
代码(G++):
#include

#include

using namespace std;

double F(double x,double y)

{

    double
fx;

   
fx=6*x*x*x*x*x*x*x+8*x*x*x*x*x*x+7*x*x*x+5*x*x-x*y;

    return
fx;

}

double f(double x,double y)

{

    double
fx;

   
fx=42*x*x*x*x*x*x+48*x*x*x*x*x+21*x*x+10*x-y;

    return
fx;

}

int main()

{

   
//freopen("in.txt", "r", stdin);

    int n;

    double
y,x1,x2,x;

   
scanf("%d",&n);

    for(int
i=0;i

    {

       
scanf("%lf",&y);

       
x1=0;

       
x2=100;

       
while(true)

       
{

           
x=(x1+x2)/2;

           
if(x2-x1<1e-6)//这里精度最小就得是1e-6

           
{

               
printf("%.4lf\n",F(x,y));

               
break;

           
}

           
else

           
{

               
if(f(x,y)==0)

               
{

                   
printf("%.4lf\n",F(x,y));

                   
break;

               
}

               
else if(f(x,y)<0)

                   
x1=x;

               
else if(f(x,y)>0)

                   
x2=x;

           
}

       
}

    
}

    
return 0;

}

Strange fuction的更多相关文章

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

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

  2. hdu 2899 Strange fuction

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

  3. hdoj 2899 Strange fuction【二分求解方程】

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

  4. 【精度问题】【HDU2899】Strange fuction

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

  5. Strange fuction

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

  6. hdu 2899 Strange fuction (二分法)

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

  7. HDU2899 Strange fuction 【二分】

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

  8. Strange fuction hdu 2899

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

  9. Hdoj 2899.Strange fuction 题解

    Problem Description Now, here is a fuction: F(x) = 6 * x^7+8x^6+7x^3+5x^2-yx (0 <= x <=100) Ca ...

随机推荐

  1. 微信bug:建议了解,不要实验,不要手贱,不要。。。。

    今天下午在群里聊天的时候,群友反应发现微信的一个bug:使用微信给好友发送‘15...............’(数字15后面加15个句号)会导致微信运行缓慢,到最后的应用未响应,退出微信. 解决办法 ...

  2. 动易CMS-搜索结果页显示自定义字段

    最终的页面: 步骤: 1.搜索标签代码 <input id="keyword" type="text" class="text" on ...

  3. E - 今年暑假不AC HDU - 2037

    "今年暑假不AC?"  "是的."  "那你干什么呢?"  "看世界杯呀,笨蛋!"  "@#$%^&* ...

  4. 安装myeclipse2015 stable 3.0破解之后发生出现SECURITY ALERT:iNTEGRITY CHECK ERROR然后闪退解决方案

    安装好myeclipse2015 stable以后也一步步按着破解文件的步骤来进行.打开myEclipse---->Subscription information--->Subscrip ...

  5. linux学习笔记:1.基础知识和命令行基本操作

    初次学习linux系统,想在这里记录自己的学习痕迹,如发现有不足之处,希望能指出,谢谢啦,之后的学习是在虚拟机VMware 10下的Red Hat Enterprise linux 6 的操作. 一. ...

  6. Hive 存储类型 StoreType

    file_format: : SEQUENCEFILE | TEXTFILE -- (Default, depending on hive.default.fileformat configurati ...

  7. 简单说明如何设置系统中的NLS_LANG环境变量

    概述:本地化是系统或软件运行的语言和文化环境.设置NLS_LANG环境参数是规定Oracle数据库软件本地化行为最简单的方式.NLS_LANG参数不但指定了客户端应用程序和Oracle数据库所使用的语 ...

  8. Python selenium 文件自动下载 (自动下载器)

    MyGithub:https://github.com/williamzxl 最新代码已经上传到Github,以下版本为stupid版本. 由于在下载过程中需要下载不同文件,所以可以把所有类型放在Va ...

  9. C#获取本周第一天和最后一天

    DateTime nowTime = DateTime.Now; #region 获取本周第一天 //星期一为第一天 int weeknow = Convert.ToInt32(nowTime.Day ...

  10. JS中的作用域以及全局变量的问题

    一. JS中的作用域 1.全局变量:函数外声明的变量,称为全部变量 局部变量:函数内部使用var声明的变量,称为局部变量在JS中,只有函数作用域,没有块级作用域!!!也就是说,if/for等有{}的结 ...