ACM:HDU 2199 Can you solve this equation? 解题报告 -二分、三分
Can you solve this equation? Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others)
Total Submission(s): Accepted Submission(s): Problem Description
Now,given the equation *x^ + *x^ + *x^ + *x + == Y,can you find its solution between and ;
Now please try your lucky. Input
The first line of the input contains an integer T(<=T<=) which means the number of test cases. Then T lines follow, each line has a real number Y (fabs(Y) <= 1e10); Output
For each test case, you should just output one real number(accurate up to decimal places),which is the solution of the equation,or “No solution!”,if there is no solution for the equation between and . Sample Input - Sample Output
1.6152
No solution! Author
Redow Recommend
lcy
数学题,直接二分,代码
#include"iostream"
#include"algorithm"
#include"cstdio"
#include"cstring"
#include"cmath"
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
#define MX 10000 + 50
using namespace std; double f(double x)
{
return *pow(x,)+*pow(x,)+*pow(x,)+*x+;
} int main()
{
int n;
double m;
while(~scanf("%d",&n))
{
for(int k=; k<=n; k++)
{
scanf("%lf",&m); double i=0.0;
if(m<f()||m>f())
{
printf("No solution!\n");continue;
}
double fr=0.0,ed=100.0;
for(; fabs(f(fr)-f(ed))>1e-;)
{
i=(fr+ed)/;
if(f(i)<m)fr=i;
else ed=i;
}
{
printf("%.4lf\n",i);
}
}
}
return ;
}
ACM:HDU 2199 Can you solve this equation? 解题报告 -二分、三分的更多相关文章
- HDU 2199 Can you solve this equation? 【浮点数二分求方程解】
		Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solution between 0 and 100; ... 
- HDU 2199 Can you solve this equation?(二分精度)
		HDU 2199 Can you solve this equation? Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == ... 
- 【LeetCode】640. Solve the Equation 解题报告(Python)
		[LeetCode]640. Solve the Equation 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: ht ... 
- hdu 2199 Can you solve this equation?(高精度二分)
		http://acm.hdu.edu.cn/howproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 MS ... 
- HDU 2199 Can you solve this equation?(二分解方程)
		传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/10 ... 
- hdu 2199 Can you solve this equation?(二分搜索)
		Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ... 
- hdu 2199:Can you solve this equation?(二分搜索)
		Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ... 
- HDU 2199 Can you solve this equation? (二分 水题)
		Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ... 
- HDU 2199 Can you solve this equation(二分答案)
		Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ... 
随机推荐
- ytu 1067: 顺序排号(约瑟夫环)
			1067: 顺序排号 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 31 Solved: 16[Submit][Status][Web Board] ... 
- JAVA 使用线程的几种方式
			之前放在自己网站上的例子,因为网站关闭,已经找不到了,想用的时候,没有的话又重新翻书是很麻烦的事情.所以重新记录一下,以备将来查看. 第一种,让任务类继承Runable接口,然后将任务类对象放入Thr ... 
- android 入门-引用库项目
			http://blog.csdn.net/arui319/article/details/6831164 
- linux使用读写锁pthread_rwlock_t
			转自:http://blog.csdn.net/onlyou930/article/details/6755593 使用读写锁 配置读写锁的属性之后,即可初始化读写锁.以下函数用于初始化或销毁读写锁. ... 
- eclipse文本编码格式修改为UTF-8 (转)
			如果要使插件开发应用能有更好的国际化支持,能够最大程度的支持中文输出,则最好使 Java文件使用UTF-8编码.然而,Eclipse工作空间(workspace)的缺省字符编码是操作系统缺省的编码,简 ... 
- jQuery.fn.extend与jQuery.extend到底区别在哪?
			正文: 其实说白了,从两个方法本身就能看出来端倪. 我们先把jQuery看成了一个类,这样好理解一些. jQuery.extend(),是扩展的jQuery这个类. 假设我们把jQuery这个类看成是 ... 
- java线程之——sleep()与wait()的区别
			sleep()是Thread的方法,wait()是Object的方法 如果线程进入了同步锁,sleep不会释放对象锁,wait会释放对象锁 sleep的作用就是让正在执行的线程主动让出CPU,给其它线 ... 
- 智能车学习(十五)——K60野火2013版例程
			一.中断函数注册方法: 1.格式: 配置某个功能的中断 注册中断函数 开启中断 2.一个例子 pit_init_ms(PIT0,);//定时中断初始化 set_vector_handler(PIT0_ ... 
- 智能车学习(十二)——智能车原理
			一.直立行走任务分解 1.任务分解 (1) 控制车模平衡:通过控制两个电机正反向运动保持车模直立平衡状态 (2) 控制车模速度:通过调节车模的倾角来实现车模速度控制,实际上最后还是演变成通过控制电机的 ... 
- SecureCRT中文显示乱码
			环境:SecureCRT登陆REDHAT5.3 LINUX系统 问题:vi编辑器编辑文件时文件中的内容中文显示乱码,但是直接使用linux系统terminal打开此文件时中文显示正常,确诊问题出现在客 ... 
