D - Equation Again
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\n",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\n",mid);
}
return 0;
}
D - Equation Again的更多相关文章
- CodeForces460B. Little Dima and Equation
B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input s ...
- ACM: FZU 2102 Solve equation - 手速题
FZU 2102 Solve equation Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & ...
- HDU 5937 Equation
题意: 有1~9数字各有a1, a2, -, a9个, 有无穷多的+和=. 问只用这些数字, 最多能组成多少个不同的等式x+y=z, 其中x,y,z∈[1,9]. 等式中只要有一个数字不一样 就是不一 ...
- coursera机器学习笔记-多元线性回归,normal equation
#对coursera上Andrew Ng老师开的机器学习课程的笔记和心得: #注:此笔记是我自己认为本节课里比较重要.难理解或容易忘记的内容并做了些补充,并非是课堂详细笔记和要点: #标记为<补 ...
- CF460B Little Dima and Equation (水题?
Codeforces Round #262 (Div. 2) B B - Little Dima and Equation B. Little Dima and Equation time limit ...
- Linear regression with multiple variables(多特征的线型回归)算法实例_梯度下降解法(Gradient DesentMulti)以及正规方程解法(Normal Equation)
,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, , ...
- ACM:HDU 2199 Can you solve this equation? 解题报告 -二分、三分
Can you solve this equation? Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Su ...
- [ACM_数学] Counting Solutions to an Integral Equation (x+2y+2z=n 组合种类)
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27938#problem/E 题目大意:Given, n, count the numbe ...
- hdu 2199 Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- SGU 106 The equation
H - The equation Time Limit:250MS Memory Limit:4096KB 64bit IO Format:%I64d & %I64u Subm ...
随机推荐
- Unity Alpha融合参数(便查)
Alpha Blending,中文译作Alpha混合 Blending就是控制透明的.处于光栅化的最后阶段. 这里例如我们给一个模型贴一个材质,那么在某个点计算出来颜色值称为源,而该点之前累积的颜色值 ...
- iSpy免费的开源视频监控平台
iSpy包括英文,Deutsch,Español,Française,Italiano和中文的翻译 iSpy是我们免费的开源视频监控平台.iSpy作为安装的Windows应用程序运行,具有完整的本地用 ...
- orocos_kdl学习(二):KDL Tree与机器人运动学
KDL(Kinematics and Dynamics Library)中定义了一个树来代表机器人的运动学和动力学参数,ROS中的kdl_parser提供了工具能将机器人描述文件URDF转换为KDL ...
- Caused by: java.lang.ClassNotFoundException: Cannot find class解决办法
mapper.xml中resultMap导致的.
- windows下vbs脚本隐藏控制台
每次想写python代码时,都需要打开IDE进行编写,并且需要创建许多小文件.如果使用jupyter就能够直接书写.但是jupyter需要手动通过控制台打开,这不够方便.通过把jupyter note ...
- CSS之定位,relative/absolute/fixed的用法
其实position的值有四个,static/relative/absolute/fixed,而static是默认值,不算具有有定位属性,这里就不讲了. 定位其实就是跟元素设置定位属性,然后设置其对位 ...
- [转]oracle 常用的指令
1.显示当前用户名 select user from dual; show user 2.显示当然用户有哪些表 select * from tab; 3.显示当所有用户的表 select * from ...
- 合理设置apache httpd的最大连接数
来自:http://hi.baidu.com/rainchen/blog/item/095f0a551fa802c5b645ae46.html 手头有一个网站在线人数增多,访问时很慢.初步认为是服务器 ...
- Asp.Net EF查看生成sql(MiniProfiler)
查看ef生成的sql有很多种方法,这里介绍两种几种的方法 方法1:浏览器直接方法/Home/getsql直接查看sql //方法1:浏览器直接方法/Home/getsql直接查看sql public ...
- 8个非常个性化的CSS3单/复选框
单选框和复选框在网页表单中应用十分广泛,但是浏览器默认自带的单选框和复选框样式不仅不统一,而且大多都比较简单丑陋.本文给大家介绍了一些基于CSS3的个性化单选框和复选框,一些选中动画是基于jQuery ...