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 ...
随机推荐
- POJ3069(贪心+巧用优先队列)
题目传送门:http://poj.org/problem?id=3069 题目大意:一个直线上有N个点.点i的距离是Xi.从这些点中选取若干个加上标记.要求:对于每个点,与其距离为R的范围内必有做标记 ...
- 最详细的PHP flush()与ob_flush()的区别详解
buffer ---- flush()buffer是一个内存地址空间,Linux系统默认大小一般为4096(1kb),即一个内存页.主要用于存储速度不同步的设备或者优先级不同的 设备之间传办理数据的区 ...
- 多年iOS开发经验总结
总结了几个月的东西终于能和大家分享了,不多说,直接看东西! 1.禁止手机睡眠 1 [UIApplication sharedApplication].idleTimerDisabled = YES; ...
- 深入理解计算机系统chapter1
---恢复内容开始--- 预处理器+编译器+汇编器+链接器=编译系统 运行hello程序 操作系统: 无论是在单核还是多核系统中,一个CPU看上去都在并发的执行多个进程,这是通过处理器在进程间切换来实 ...
- JAVA设计模式总结之23种设计模式
上一篇总结了设计模式的六大原则<JAVA设计模式总结之六大设计原则>,这一篇,正式进入到介绍23种设计模式的归纳总结. 一.什么是设计模式 ...
- Spark组件
1,Application application(应用)其实就是用spark-submit提交的程序.比方说spark examples中的计算pi的SparkPi.一个application通常包 ...
- caffe源码 卷积层
通俗易懂理解卷积 图示理解神经网络的卷积 input: 3 * 5 * 5 (c * h * w) pading: 1 步长: 2 卷积核: 2 * 3 * 3 * 3 ( n * c * k * k ...
- jQuery经典案例
示例1:鼠标点击左侧菜单实现打开和关闭功能: html及css代码部分: <!DOCTYPE html> <html lang="en"> <head ...
- zoj 1874 水题,输出格式大坑
Primary Arithmetic Time Limit: 2 Seconds Memory Limit: 65536 KB Children are taught to add mult ...
- 超全面!这可能是最全面的 jQuery 知识总结
个人建议:学习 jQuery 前先掌握基本的 JavaScrpit 语法,特别是对函数要掌握,jQuery 基本上是使用函数. jQuery 简介 jQuery 是一个轻量级 JavaScript 库 ...