UVa - 10341
2024-09-20 18:34:58
Solve the equation:
p ∗ e ^−x + q ∗ sin(x) + r ∗ cos(x) + s ∗ tan(x) + t ∗ x ^2 + u = 0
2 + u = 0
where 0 ≤ x ≤ 1.
Input
Input consists of multiple test cases and terminated by an EOF. Each test case consists of 6 integers in
a single line: p, q, r, s, t and u (where 0 ≤ p, r ≤ 20 and −20 ≤ q, s, t ≤ 0). There will be maximum
2100 lines in the input file.
Output
For each set of input, there should be a line containing the value of x, correct up to 4 decimal places,
or the string ‘No solution’, whichever is applicable.
Sample Input
0 0 0 0 -2 1
1 0 0 0 -1 2
1 -1 1 -1 -1 1
Sample Output
0.7071
No solution
0.7554
解题思路:
直接二分从0.0000搜到1.0000,搜到就输入没搜到就返回-1;注意这个函数是递减的
二分代码:
double solve()
{
double low=,high=,mid;
if(fuck(low)*fuck(high)>)
return -;
while(high-low>1e-)
{
mid = low+(high-low)/;
if(fuck(mid)<)
high=mid;
else
low=mid;
}
return low;
}
最新文章
- angular2系列教程(十)两种启动方法、两个路由服务、引用类型和单例模式的妙用
- 用SignalR 2.0开发客服系统[系列2:实现聊天室]
- CSS中如何让元素隐藏
- delphi之多线程编程
- Spring基础知识汇总
- Jmeter之JDBC Request使用方法(oracle)
- This task is currently locked by a running workflow and cannot be edited
- 今年暑假不AC[HDU2037]
- WebService 的一些基本概念
- 检测php网站是否已经被攻破
- Vim简明教程【CoolShell】
- E - Speed Limit(2.1.1)
- libvirt里的面向对象的C语言
- Android应用系列:仿MIUI的Toast动画效果实现(有图有源码)
- 小学生四则运算出题软件-基于java控制台的实现
- 搭建ssm框架
- Mac 下如何下载、启动和关闭Tomcat 和管理Mac自带的Apache
- IIS 的几个小技巧
- call apply 使用
- Sublime Text 2之Emmet插件安装及使用