(二分搜索 )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 ( ...
随机推荐
- 阿里云OSS linux使用备忘录
ossutil config example: accessKeyId = "AccessKeyId"; accessKeySecret = "AccessKeySecr ...
- 洛谷[P1002]过河卒
原题地址:https://www.luogu.org/problemnew/show/P1002 题目描述 棋盘上A点有一个过河卒,需要走到目标B点.卒行走的规则:可以向下.或者向右.同时在棋盘上C点 ...
- linux编程基本
库的使用头文件:.h 里面的函数及变量的声明 比如#include <stdio.h> ,Linux下默认头文件的搜索路径 系统定义的头文件: /usr/include /usr/loca ...
- Bootstrap-CL:警告
ylbtech-Bootstrap-CL:警告 1.返回顶部 1. Bootstrap 警告(Alerts) 本章将讲解警告(Alerts)以及 Bootstrap 所提供的用于警告的 class.警 ...
- Hive常用函数
字符串函数 字符串长度函数:length 语法: length(string A) 返回值: int 说明:返回字符串A的长度 举例: hive> select length(‘abcedfg’ ...
- 【Codeforces】Codeforces Round #491 (Div. 2) (Contest 991)
题目 传送门:QWQ A:A - If at first you don't succeed... 分析: 按照题意模拟 代码: #include <bits/stdc++.h> usin ...
- python logging 重复写日志问题
用Python的logging模块记录日志时,遇到了重复记录日志的问题,第一条记录写一次,第二条记录写两次,第三条记录写三次...很头疼,这样记日志可不行.网上搜索到了原因与解决方案: 原因:没有移除 ...
- 消息队列kafka
消息队列kafka 为什么用消息队列 举例 比如在一个企业里,技术老大接到boss的任务,技术老大把这个任务拆分成多个小任务,完成所有的小任务就算搞定整个任务了. 那么在执行这些小任务的时候,可能 ...
- Advanced Simulation Library(ASL)&& An adaptive and distributed-memory parallel implementation of the immersed boundary (IB) method (IBAMR)
How to install asl and ibamr tools: ASL 和 IBAMR 都是有限元分析的工具,流体力学等,ASL可以使用GPU加速计算, 主机配置,i7 6代,1060, 32 ...
- string类型版本号比较
直接上代码吧: boolean CompareVersion(string softVersion1, string softVersion2) { ) { return true; } return ...