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 ...
随机推荐
- Zookeeper单机伪集群
Zookeeper单机伪集群 1.配置 zookeeper下载地址:http://apache.mirrors.lucidnetworks.net/zookeeper/ 可以选择需要的版本,我下载的是 ...
- angular default project (angular.json的解读)
Change the default Angular project Understanding it's purpose and limits Klaus KazlauskasFollow Nov ...
- python新建txt文件,并逐行写入数据
#coding=utf-8 txtName = "codingWord.txt"f=file(txtName, "a+")for i in range(1,10 ...
- 树莓派3中编译Opencv3.4.10
一.命令 -dev libv4l-dev libavcodec-dev libavformat-dev libswscale-dev cd wget http://sourceforge.net/pr ...
- 鼠标滑过table时修改表格行的背景颜色
方法一: #customers tr:hover { background-color: #f00; } 方法二: <tr onmouseover="style.backgroundC ...
- WEBAPI 的简单示例
一.webapi 1.在webapiconfig中移除xml的返回格式,返回格式就自动使用Json格式 config.Formatters.Remove(config.Formatters.XmlFo ...
- 搞定所有的跨域请求问题 jsonp CORS
网上各种跨域教程,各种实践,各种问答,除了简单的 jsonp 以外,很多说 CORS 的都是行不通的,老是缺那么一两个关键的配置.本文只想解决问题,所有的代码经过亲自实践. 本文解决跨域中的 ge ...
- AndroidManifest: windowSoftInputMode属性总结
在Android中,可以通过给Activity设置windowSoftInputMode这个属性来控制软键盘与Activity的主窗口的交互方式. 1. 当Activity成为用户注意的焦点时软键盘的 ...
- 【工具】我的Git学习日志
使用github一段时间,一直使用的是可视化工具,配合公司转用git,提前联系下git的命令. 安装 windows上安装git 从git for windows下载安装包,我下的是Git-2.13. ...
- 初试 Kubernetes 集群中使用 Traefik 反向代理
初试 Kubernetes 集群中使用 Traefik 反向代理 2017年11月17日 09:47:20 哎_小羊_168 阅读数:12308 版权声明:本文为博主原创文章,未经博主允许不得转 ...