(二分搜索 )Strange fuction -- HDU -- 2899
链接:
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
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.
100
200
-178.8534
代码:
- #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的更多相关文章
- Strange fuction hdu 2899
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- hdu 2899 Strange fuction
http://acm.hdu.edu.cn/showproblem.php?pid=2899 Strange fuction Time Limit: 2000/1000 MS (Java/Others ...
- 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 (二分法)
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- 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 ...
- HDU2899 Strange fuction 【二分】
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 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 ( ...
随机推荐
- [C++ Primer] 第3章: 字符串, 向量和数组
标准库类型string string初始化 string s2(s1); string s2 = s1; string s3("value"); string s3 = " ...
- rabbitMQ应用,laravel生产广播消息,springboot消费消息
最近做一个新需求,用户发布了动态,前台需要查询,为了用户读取信息响应速度更快(MySQL很难实现或者说实现起来很慢),所以在用户动态发布成功后,利用消息机制异步构建 redis缓存 和 elastic ...
- Form中的keypress事件不能用
Form中的keypress事件不能用 编写人:CC阿爸 2015-4-8 近期在修改系统时,想给一画面增加一个组合键功能,但在form_keypress事件中加入代码,但无论如何也不能触发该动作. ...
- 善待Erlang 代码 -- Xref 实践
Xref 是一个交叉引用工具,通过分析定义的函数间的调用关系,用于查找函数. 模块. 应用程序和版本之间的依赖关系. 通俗而言,Xref 可以检查代码中函数的调用关系.比如在 moduleA 中的 f ...
- 微信小程序获取用户openid,头像昵称信息,后台java代码
https://blog.csdn.net/qq_39851704/article/details/79025557
- 汇编_指令_SUB
SUB是减法运算. 比如mov ax,2mov bx,1sub ax,bx 其中sub ax,bx就是ax中的值减bx中的值,等于1,然后把结果,也就是1,放入ax中.
- undefined和NAN的区别(转)
Javascript 中 null.NaN和undefined的区别 1.类型分析: js中的数据类型有undefined,boolean,number,string,object等5种,前4种为原始 ...
- javascript的创建对象object.create()和属性检测hasOwnPrototype()和propertyIsEnumerable()
Object.create("参数1[,参数2]")是E5中提出的一种新的对象的创建方式. 第一个参数是要继承到新对象原型上的对象; 第二个参数是对象属性.这个参数可选,默认为fa ...
- 阿里云短信接口python版本
# -*- coding: utf-8 -*- #!/usr/bin/python #encoding=utf-8 import sys from aliyunsdkdysmsapi.request. ...
- 公共文件模块include
首先新建一个include 把所有引入的文件放入公共文件里 function getBaseURL() { var pathName = window.document.location.pathna ...