(二分搜索 )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 ( ...
随机推荐
- Web验证方式(4)--JWT
OAuth协议中说到的AccessToken可以是以下两种: 1.任意只起到标识作用的字符串:这种情况下Resource Server处理请求时需要去找Authorization Server获取用户 ...
- debian7配置iptables
vim /etc/iptables.rule 文件内容如下 *filter # Allows all loopback (lo0) traffic and drop all traffic to / ...
- api proxy设置 后端服务器代理
location ^~ /api/{ ssi on; ssi_silent_errors off; proxy_redirect off; proxy_set_header Host $host; p ...
- C++11奇怪的语法
1. istream_iterator 简而言之,istream_iterator像操作容器一样操作istream.例如下面代码,从std::cin构造std::istream_iteream< ...
- poj-3253-Fence Repair(哈夫曼)
/* Fence Repair Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 19914 Accepted: 6314 Desc ...
- 《Linux内核精髓:精通Linux内核必会的75个绝技》一HACK #6 使用localmodconfig缩短编译时间
HACK #6 使用localmodconfig缩短编译时间 本节介绍使用make localmodconfig生成精简的.config文件,缩短内核编译时间的方法.为了能够应对各种各样的环境,发布版 ...
- 集合-强大的集合工具类:java.util.Collections中未包含的集合工具
任何对JDK集合框架有经验的程序员都熟悉和喜欢java.util.Collections包含的工具方法.Guava沿着这些路线提供了更多的工具方法:适用于所有集合的静态方法.这是Guava最流行和成熟 ...
- 使用TCPDF输出完美的中文PDF文档
TCPDF是一个用于快速生成PDF文件的PHP5函数包.TCPDF基于FPDF进行扩展和改进.支持UTF-8,Unicode,HTML和XHTML.在基于PHP开发的Web应用中,使用它来输出PDF文 ...
- gradle 刷新缓存
gradle build --refresh-dependencies -x test
- JAVA程序中使用正则表达式
import java.util.regex.Matcher;import java.util.regex.Pattern; /** * @author Administrator 测试正则表达式 * ...