题目传送门

 /*
二分搜索:式子两边取对数,将x提出来,那么另一边就是一个常数了,函数是:lnx/x。二分搜索x,注意要两次
*/
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std; const double e = exp (1.0); double cal(double x) {
return log (x) / x;
} int main(void) { //HDOJ 2675 Equation Again
//freopen ("HDOJ_2675.in", "r", stdin); double y, k;
while (scanf ("%lf", &y) == ) {
k = ( + log (y)) / (e * y);
//if (k > 1 / e) { //囧!
// puts ("Happy to Women’s day!"); continue;
//}
if (k == / e) {
printf ("%.5f\n", e); continue;
} double x1, x2;
double l = , r = e;
for (int i=; i<=; ++i) {
double mid = (l + r) / ;
if (cal (mid) >= k) r = mid;
else l = mid;
}
x1 = l;
l = e, r = 1e9;
for (int i=; i<=; ++i) {
double mid = (l + r) / ;
if (cal (mid) >= k) l = mid;
else r = mid;
}
x2 = l;
printf ("%.5f %.5f\n", x1, x2);
} return ;
}

二分搜索 HDOJ 2675 Equation Again的更多相关文章

  1. 二分搜索 HDOJ 2289 Cup

    题目传送门 /* 二分搜索:枚举高度,计算体积与给出的比较. */ #include <cstdio> #include <algorithm> #include <cs ...

  2. HDU 2675 Equation Again

    公式转化+二分答案 首先,把题目中给的等式转化一下,变成了这个样子. 等式右边的值是可以求出来的. ln(x)/x的大致图像是这样的 那么只要对[0,e]和[e,+∞]分别进行二分答案即可. #inc ...

  3. hdu 2199 Can you solve this equation?(二分搜索)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  4. hdu 2199:Can you solve this equation?(二分搜索)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  5. hdoj 2199 Can you solve this equation?【浮点型数据二分】

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  6. HDOJ 4249 A Famous Equation DP

    DP: DP[len][k][i][j] 再第len位,第一个数len位为i,第二个数len位为j,和的第len位为k 每一位能够从后面一位转移过来,能够进位也能够不进位 A Famous Equat ...

  7. Hdoj 2199.Can you solve this equation? 题解

    Problem Description Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solutio ...

  8. (二分搜索)Can you solve this equation? -- hdu -- 2199

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=2199 Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  9. 二分搜索 2015百度之星初赛1 HDOJ 5248 序列变换

    题目传送门 /* 二分搜索:在0-1e6的范围找到最小的max (ai - bi),也就是使得p + 1 <= a[i] + c or a[i] - c 比赛时以为是贪心,榨干智商也想不出来:( ...

随机推荐

  1. 家的范围 Home on the Range(洛谷 2733)

    题目背景 农民约翰在一片边长是N (2 <= N <= 250)英里的正方形牧场上放牧他的奶牛.(因为一些原因,他的奶牛只在正方形的牧场上吃草.)遗憾的是,他的奶牛已经毁坏一些土地.( 一 ...

  2. C++字符串读入

    int read() { ,f=;char ch=getchar(); ;ch=getchar();} +ch-';ch=getchar();} return x*f; } int main() { ...

  3. 【NOIP2016】天天爱跑步(树上差分)

    题意: 小c同学认为跑步非常有趣,于是决定制作一款叫做<天天爱跑步>的游戏.?天天爱跑步?是一个养成类游戏,需要 玩家每天按时上线,完成打卡任务.这个游戏的地图可以看作一一棵包含 N个结点 ...

  4. 【ZJOI2017 Round1练习&BZOJ5350】D5T1 masodik(DP,斜率优化)

    题意:你要从(0,0)点走到(n,m), 每次只能往 x 轴或者 y 轴正方向移动一个单位距离.从(i,j)移动到(i,j+1)的代价为 ri,从(i,j)移动到(i+1,j)的代价为 cj. 求最小 ...

  5. JavaScript面向对象实现

    JavaScript面向对象实现 一:面向对象三大特征 继承,封装,多态! 二:JavaScript自定义对象  创建对象的方式: 方式1,对象初始化器方式: <script type=&quo ...

  6. Divide Two Integers(模拟计算机除法)

    Divide two integers without using multiplication, division and mod operator. 由于不能用乘号,除号,和取余.那么一个数除另外 ...

  7. Remove Element(第一种方法参考别人)

    Given an array and a value, remove all instances of that value in place and return the new length. T ...

  8. 解析excel文件并将数据导入到数据库中

    今天领导给安排了一个临时工作,让我将一个excel里面的数据解析后放入数据库中,经过一个下午的努力成功完成,现在将代码献上,希望对大家有所帮助 一.需要导入的jar 1.commons-collect ...

  9. js 合并对象

    对象的合并 需求:设有对象 o1 ,o2,需要得到对象 o3 var o1 = { a:'a' }, o2 = { b:'b' }; // 则 var o3 = { a:'a', b:'b' } 方法 ...

  10. log4j 具体解释

    通常,我们都提供一个名为 log4j.properties的文件.在第一次调用到Log4J时,Log4J会在类路径(../web-inf/class/当然也能够放到其他不论什么文件夹.仅仅要该文件夹被 ...