Strange fuction
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.
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)
minimum value (accurate up to 4 decimal places),when x is between 0
and 100.
#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的更多相关文章
- ACM : HDU 2899 Strange fuction 解题报告 -二分、三分
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- hdu 2899 Strange fuction
http://acm.hdu.edu.cn/showproblem.php?pid=2899 Strange fuction Time Limit: 2000/1000 MS (Java/Others ...
- hdoj 2899 Strange fuction【二分求解方程】
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- 【精度问题】【HDU2899】Strange fuction
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Strange fuction
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- hdu 2899 Strange fuction (二分法)
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- HDU2899 Strange fuction 【二分】
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Strange fuction hdu 2899
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- 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 ...
随机推荐
- css左右布局的几种实现方式和优缺点
记录一下左右布局的实现方式,实现的具体效果是,左侧固定宽度,高度适中等于父元素的高度,父元素的高度由右侧内容决定: html代码如下: <div class="parent" ...
- AngularJS -- Bootstrap(启动器)
点击查看AngularJS系列目录 转载请注明出处:http://www.cnblogs.com/leosx/ Bootstrap(初始化) 这章介绍了Angular的初始化过程,以及如何在必要的时候 ...
- Maven(六)之依赖管理
前面讲了maven一些关于Maven的简单知识,今天我给大家分享一些Maven的依赖管理.我相信用过maven的人都知道,它很重要的功能就是通过依赖来添加jar包. 让我们领略一下Maven是怎么管理 ...
- CentOSv6.8 修改防火墙配置、修改SSH端口
查看防火墙目前使用状况: service iptables status 修改防火墙配置: vi /etc/sysconfig/iptables 重启防火墙,让刚才修改的配置生效: service i ...
- D. Mysterious Present (看到的一个神奇的DP,也可以说是dfs)
D. Mysterious Present time limit per test 2 seconds memory limit per test 64 megabytes input standar ...
- hdu3065 ac自动机
病毒侵袭持续中 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- hdu3974 找上属的模拟
There is a company that has N employees(numbered from 1 to N),every employee in the company has a im ...
- vscode 调试.net core 2.0 输出乱码解决方法
之前在vscode上调试.net core 2.0项目时输出窗口一直是乱码,查了很多资料无法解决 最终在github找到了解决办法 -> https://github.com/OmniSha ...
- Linux下安装与配置Nginx
一.准备 Nginx版本:nginx-1.7.7.tar.gz 请自行到官网下载对应的版本. 二.步骤 ♦在Linux新建一个queenLove用户 [root@localhost /]# use ...
- C#.net干货,最全公共帮助类
比较全面的c#帮助类,日常工作收集,包括前面几家公司用到的,各式各样的几乎都能找到,所有功能性代码都是独立的类,类与类之间没有联系,可以单独引用至项目,分享出来,方便大家,几乎都有注释,喜欢的请点赞, ...