Strange fuction

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

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
 
分析:这个题是要求方程的最小值,首先我们来看一下他的导函数: F’(x) = 42 * x^6+48*x^5+21*x^2+10*x-y(0 <= x <=100)
很显然,导函数是递增的,那么只要求出其导函数的零点就行了,下面就是用二分法求零点!
 
 #include<stdio.h>
#include<math.h>
double hs(double x,double y)
{
return *pow(x,)+*pow(x,)+*pow(x,)+*x*x-y*x;//定义一个求函数值得函数
}
double ds(double x,double y)
{
return *pow(x,)+*pow(x,)+*pow(x,)+*x-y;//定义一个求导数的函数
}
int main()
{
int a;
scanf("%d",&a);
while(a--)
{
double b,x,y,z;
scanf("%lf",&b);
x=0.0;
y=100.0;
do
{
z=(x+y)/;
if(ds(z,b)>)
y=z;
else
x=z;
}while(y-x>1e-);//求出一定精度内导数为0的大约值
printf("%.4lf\n",hs(z,b));
}
return ;
}
 下面是我刚学的三分法:
 
 
 #include<stdio.h>
#include<math.h>
double hs(double x,double y)
{
return *pow(x,)+*pow(x,)+*pow(x,)+*x*x-y*x;
}
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
double l,r,mid,midmid,a;
scanf("%lf",&a);
l=0.0;
r=100.0;
do
{
mid=(l+r)/;
midmid=(mid+r)/;
if(hs(mid,a)>hs(midmid,a))
l=mid;
else
r=midmid;
}while(r-l>1e-);
printf("%.4lf\n",hs(mid,a));
}
return ;
}
 
 

Strange fuction--hdu2899的更多相关文章

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

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

  2. HDU2899 Strange fuction 【二分】

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

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

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

  4. hdu 2899 Strange fuction

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

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

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

  6. Strange fuction

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

  7. hdu 2899 Strange fuction (二分法)

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

  8. Strange fuction hdu 2899

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

  9. hdu2899 Strange fuction

    在区间(0,100).在恒大二阶导数0.f(x)有极小值.用的最低要求的一阶导数值点: #include<math.h> #include<stdio.h> #include& ...

  10. Strange fuction

    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 <=1 ...

随机推荐

  1. [Javascript]史上最短的IE浏览器判断代码

    今天发现个很有趣的js判断全世界最短的代码,想想之前自己写的判断ie浏览器的,这个实在简单多了 var ie = !+"\v1"; 仅仅需要7bytes!参见这篇文章,<32 ...

  2. 【python学习笔记01】python的数据类型

    python的基本数据类型 整型 int 浮点型 float 真值 bool 字符串 str 列表 list       #[1,2,3] 元组 tuple    #(1,2,3) 字典 dict   ...

  3. Apple Catching(POJ 2385)

    Apple Catching Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9978   Accepted: 4839 De ...

  4. 手把手教你学习FPGA系列视频教程_救护车鸣笛声

    本套教程主要面对FPGA初学者,本次DIY活动不仅让初学者掌握FPGA硬件电路设计以及焊接方面的知识,更重要的是让初学者学习硬件描述语言 (VerilogHDL)描述数字电路,以及Quartus II ...

  5. 前端MVVM学习之KnockOut(一)

    MVVM理解 MVVM即Model-View-viewModel,是微软WPF和MVP(Model-View-Presenter)结合发展演变过来的一种新型架构框架. MVVM设计模式有以下优点: ( ...

  6. Ubuntu14.04LST 安装Oracle SQL Developer 4.0.2

    1:Oracle SQL Developer 4.0.2下载链接: http://www.oracle.com/technetwork/developer-tools/sql-developer/do ...

  7. 外贸中MFQ

    MFQ = Mask Fee Quantity 退掩膜费量Masking charge USD 2000. MFQ 100k in the first year

  8. setTimeout()使用

    Basic setTimeout() Example setTimeout(function() {       // Do something after 5 seconds }, ); Tip:  ...

  9. VMware 虚拟机的网络连接方式详解

         VMWare提供了三种工作模式,它们是bridged(桥接模式).NAT(网络地址转换模式)和host-only(主机模式).要想在网络管理和维护中合理应用它们,你就应该先了解一下这三种工作 ...

  10. JFreeChart多坐标轴曲线图

    jar包:jcommon-1.0.23.jarjfreechart-1.0.19.jar maven配置: <dependency> <groupId>jfree</gr ...