链接:

http://acm.hdu.edu.cn/showproblem.php?pid=2899

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

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
 
42 * x^6+48*x^5+21*x^2+10*x = y
x 要是 double 类型的, 左边要尽可能接近右边的 y 值
再带入F(x)中
F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x

代码:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h> #define N 150
#define D (1e-6) double f(double x)
{
return *pow(x, 6.0) + *pow(x, 5.0) + *pow(x, 2.0) + *x;
} double F(double x)
{
return *pow(x, 7.0) + *pow(x, 6.0) + *pow(x, 3.0) + *pow(x, 2.0);
} int main()
{ int t;
scanf("%d", &t); while(t--)
{
int y; scanf("%d", &y); if(y>=f())
printf("%.4f\n", F()-*y);
else
{ double L=, R=, m; while(R-L>D)
{
m = (L+R)/;
if(f(m)<=y) L=m;
else R=m;
} printf("%.4f\n", F(L)-L*y);
}
}
return ;
}

(二分搜索 )Strange fuction -- HDU -- 2899的更多相关文章

  1. Strange fuction hdu 2899

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

  2. hdu 2899 Strange fuction

    http://acm.hdu.edu.cn/showproblem.php?pid=2899 Strange fuction Time Limit: 2000/1000 MS (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 (二分法)

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

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

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

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

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

  7. Strange fuction

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

  8. HDU2899 Strange fuction 【二分】

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

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

随机推荐

  1. 差分进化算法-python实现

    DEIndividual.py import numpy as np import ObjFunction class DEIndividual: ''' individual of differen ...

  2. storyboard貌似不错

    冷静下来看了下,貌似聽简单,蛋疼,忙完才发现,弄的时候咋没发现,靠 push,present等可以全部用下面这个api搞定 - (void)performSegueWithIdentifier:(NS ...

  3. springMVC国际化配置和使用

    下面是基于session的,springMVC国际花的一个例子: 需求是 输入url:展示中文界面 http://localhost:8080/MySSM/user?lang=zh 输入url:  展 ...

  4. Java 运用流传输文件

    实例1 package IO; import java.io.FileReader; import java.io.FileWriter; import java.io.Reader; import ...

  5. RTNETLINK answers: File exists

    问题: 重启网络时报错如下 >>/etc/init.d/network start RTNETLINK answers: File exists 分析: /etc/init.d/netwo ...

  6. setAttribute第三个参数

    object.setAttribute(sName, vValue [, iFlags]) sName参数应是Dom属性而非html中的属性.Dom中Html专有的接口属性应该以小写字母开头,如果属性 ...

  7. Solr -- 查询语法/参数

    1. 常用查询参数 参数 描述 defType 指定用于处理查询语句(参数q的内容)的查询解析器,eg:defType=lucene sort 指定响应的排序方式:升序asc或降序desc.同时需要指 ...

  8. linux nginx安装以及配置

    一.Nginx简介 Nginx (“engine x”) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器.Nginx是由Igor Sysoev为俄罗斯访问量第二的R ...

  9. python入门第3篇 pycharm安装及使用

    内容: 1. python开发工具的介绍及安装 2.pycharm的设置及技巧 一.python开发工具的介绍及安装 python下载后就自带了一个官方的IDE,官方的IDE我个人觉得不是很好用,所以 ...

  10. IOS学习计划

    自从接触了IOS后,都没有像样的写过一篇博客去总结这近三个月来对IOS开发的了解.今天,趁着有那么一点的时间,写一下接下来的学习计划和学习路线,以便于自己今后接下来的时间可以更有方向感,更有效率的去学 ...