Strange fuction

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

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
题解:先对方程求导,对求导后的方程求x,则此时由数学知识可得解除的x为原方程的一个极小值;带入原方程即可
#include<stdio.h>
#include<string.h>
#include<math.h>
double y;
double f(double x)
{
return 6*pow(x,7)+8*pow(x,6)+7*pow(x,3)+5*pow(x,2)-y*x;
}
double f1(double x)
{
return 42*pow(x,6)+48*pow(x,5)+21*pow(x,2)+10*x;
}
int main()
{
int t;
double l,r,mid,len;
scanf("%d",&t);
while(t--)
{
scanf("%lf",&y);
l=0;r=100;mid;
while(r - l > 1e-8)
{
mid = ( r + l ) / 2;
if(f1(mid)<y)
l=mid;
else
r=mid;
}
len=f(r);
printf("%.4lf\n",len);
}
return 0;
}

  

hdoj 2899 Strange fuction【二分求解方程】的更多相关文章

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

  2. HDU 2899 Strange fuction [二分]

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

  3. hdu 2899 Strange fuction

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

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

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

  5. hdu 2899 Strange fuction (二分法)

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

  6. 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 ( ...

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

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

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

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

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

随机推荐

  1. Python:字典

    #!/usr/bin/python3 #dict 字典 #字典是可变的 dict1 = {"name":"张三","age":22} pri ...

  2. 使用Eclipse把java文件打包成jar 含有第三方jar库的jar包

    使用Eclipse把java文件打包成jar 含有第三方jar库的jar包   网上打包说用eclipse安装fat jar插件,但是貌似现在都不能用了,所以我只能按照eclipse自带的方法打包了. ...

  3. CSS3圆角(border-radius)

    CSS3中的border-radius支持IE9+,chrome,firefox 2.3+,以及safari3.2+浏览器. border-radius可直接使用,无需加前缀(注意:firefox13 ...

  4. php完整验证码代码

    <?php require_once 'string.func.php'; //通过GD库做验证码 /** *添加验证文字 * @param int $type * @param int $le ...

  5. Android中使用WebView与JS交互全解析

    1.概述首先,需要提出一个概念,那就是hybrid,主要意思就是native原生Android和h5混合开发.为什么要这样做呢?大家可以想象一下针对于同一个活动,如果使用纯native的开发方式,An ...

  6. React Native:使用 JavaScript 构建原生应用 详细剖析

    数月前,Facebook 对外宣布了正在开发的 React Native 框架,这个框架允许你使用 JavaScript 开发原生的 iOS 应用——就在今天,Beta 版的仓库释出了! 基于 Pho ...

  7. ng-html 报 不安全 警告解决办法

    app.filter('to_trusted',['$sce',function($sce){ return function(text){ return $sce.trustAsHtml(text) ...

  8. 手动实现 NSTabViewController 的 Rect Transition 及 Propagate Title-b

    不知为何 我在 OS X 10.11.5 及 Xcode 7.3 的 Storyboard 中设置 Tab View Controller 的 Transition 属性时,Tab View Cont ...

  9. iOS应用如何支持IPV6-b

    果然是苹果打个哈欠,iOS行业内就得起一次风暴呀.自从5月初Apple明文规定所有开发者在6月1号以后提交新版本需要支持IPV6-Only的网络,大家便开始热火朝天的研究如何支持IPV6,以及应用中哪 ...

  10. 一个消除if语句的例子

    // 一个按钮点击事件,判断点击按钮是那一个显示出他的信息 - (IBAction)buttonPressed:(id)sender { if (sender == self.leftButton) ...