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. jQuery分析(1) - 介绍

    前言 web技术高速发展到现在已经出了现非常多的库或框架,库或框架实现方法也是五花八门.现在要实现一个web站点只需要根据自己的业务需求选择js框架即可快速完成.有些框架可以快速满足业务需求,但是有些 ...

  2. STUN/TURN/ICE协议在P2P SIP中的应用(二)

    1       说明 2       打洞和穿越的概念... 1 3       P2P中的打洞和穿越... 2 4       使用STUN系列 协议穿越的特点... 2 5       STUN/ ...

  3. ACM YTU 1012 u Calculate e

    u Calculate e Problem Description A simple mathematical formula for e is where n is allowed to go to ...

  4. QTableView使用自定义委托(QItemDelegate)

    需要在表格中绘制流程图,主要有箭头,方向,颜色,字符串,由于QTableView没有可用的绘制函数,所以需要自己去定义. 委托(delegate)继承QItemDelegate,模型(model)继承 ...

  5. html5+css3实现上拉和下拉刷新

    <!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content=& ...

  6. 创建对象的两种方法: new 和 面向对象(对象字面量)及对象属性访问方法

    创建对象的两种方法: new 和 面向对象(对象字面量)用 new 时:var o = new Object();o.name = "lin3615";alert(o.name); ...

  7. 怎样让老浏览器兼容html5新标签

    CSS样式设置默认样式: <style> article, aside, canvas, details, figcaption, figure, footer, header, hgro ...

  8. css3多行省略号

    -webkit-line-clamp 概述: -webkit-line-clamp 是一个 不规范的属性(unsupported WebKit property),它没有出现在 CSS 规范草案中. ...

  9. Apache 支持PHP

    ①加载PHP模块到Apache中: LoadModule php5_module "d:\php5\php5apache2_2.dll"   ②加入识别扩展名为.php文件(也可以 ...

  10. github避免每次输入账户密码

    方法1: 显示所有隐藏目录,找到目录./git下的文件config文件,通过文本方式打开,在最前面添加如下两行.之后再次输入一次密码后就会记住账号密码. [credential]     helper ...