• D


    This problem’s author is too lazy to write the problem description, so he only give you a equation like X (eY) == (eY) x, and the value of Y, your task is calculate the value of X.
    Note : here e is the Natural logarithm.

    Input

    Each line will contain one number Y(Y >= 1). Process to end of file.

    Output

    For each case, output X on one line, accurate to five decimal places, if there are many answers, output them in increasing order, if there is no answer, just output “Happy to Women’s day!”.

    Sample Input

    1

    Sample Output

    2.71828

    二分就好了,只有1的时候才只有一个答案,其他都是2个,注意输出5位小数我是个傻子

    #include<iostream>
    #include<stdio.h>
    #include<stdlib.h>
    #include <iomanip>
    #include<cmath>
    #include<float.h> 
    #include<string.h>
    #include<algorithm>
    #define sf scanf
    #define pf printf
    #define pb push_back
    #define mm(x,b) memset((x),(b),sizeof(x))
    #include<vector>
    #include<map>
    #define for(i,a,b) for(int i=a;i<b;i++)
    typedef long long ll;
    typedef long double ld;
    typedef double db;
    const ll mod=1e12+100;
    const db e=exp(1);
    using namespace std;
    const double pi=acos(-1.0);
    db ans;
    int judge(db mid)
    {
    	db cas=log(mid)/mid;
    	if(cas==ans) return 0;
    	else if(cas<ans) return -1;
    	else if(cas>ans) return 1;
    }
    int main()
    {
    	db x,y;
    	while(~sf("%lf",&y))
    	{
    		if(y==1)
    		{
    			pf("%.5lf
    ",e);continue;
    		}
    		ans=(1+log(y))/(e*y);
    		db left=1,right=e,mid;
    		while(right-left>0.00000001)
    		{
    			mid=(left+right)/2;
    			if(judge(mid)==0) break;
    			else if(judge(mid)==1) right=mid;
    			else left=mid;
    		}
    		pf("%.5lf ",mid);
    		left=e,right=DBL_MAX;
    		while(right-left>0.00000001)
    		{
    			mid=(left+right)/2;
    			if(judge(mid)==0) break;
    			else if(judge(mid)==1) left=mid;
    			else right=mid;
    		}
    		pf("%.5lf
    ",mid);
    	}
    	return 0;
    }
    
  • 相关阅读:
    你可能不知道的js -- 数据类型转换
    项目开发过程中使用工具的相关配置 -- git / svn / 谷歌跨域
    博客园个人博客页面主题
    keep-alive指定条件缓存的坑
    element的多文件上传
    谷歌应用商店扩展程序
    从郭建的遭遇(自称最惨的创业者)看‘程序员的人生观’(一)
    我深表遗憾
    入门学习三
    编程入门学习二
  • 原文地址:https://www.cnblogs.com/wzl19981116/p/9382199.html
Copyright © 2020-2023  润新知