UVa 10341 (二分求根) Solve It
2024-10-16 18:38:13
很水的一道题,因为你发现这个函数是单调递减的,所以二分法求出函数的根即可。
#include <cstdio>
#include <cmath>
//using namespace std; const double e = 1e-;
double p, q, r, s, t, u; inline double f(double x)
{ return p*exp(-x) + q*sin(x) + r*cos(x) + s*tan(x) + t*x*x + u; } int main()
{
//freopen("in.txt", "r", stdin); while(scanf("%lf%lf%lf%lf%lf%lf", &p, &q, &r, &s, &t, &u) == )
{
if(f()<-e || f()>e) { puts("No solution"); continue; }
double L = , R = , m;
for(int i = ; i < ; i++)
{
m = (L+R)/;
if(f(m) < ) R = m;
else L = m;
}
printf("%.4f\n", m);
} return ;
}
代码君
最新文章
- 多彩的Console打印新玩法
- 微信video标签全屏无法退出bug 本文系转载
- wkwebview a target=";_blank"; 打不开链接的解决方案
- python添加tab键提示
- Objective-C:Foundation框架-常用类-NSMutableString
- EF初始化mysql数据库codefirst
- MFC 点击改变文本 加法计时器 伸缩窗体
- AngularJS创建新指令 - 基本功能
- [图形学] Chp10 OpenGL三维观察程序示例
- C++各种指针辨析
- 流量控制闸门——LimitLatch套接字连接数限制器
- Docke--Dockerfile指令介绍
- 树状数组BIT
- Unity中对系统类进行扩展的方法
- Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user&#39;s experience. For more jquery-1.12.4.js:10208
- Entity Frame Code First 简易教程
- Tensorflow学习笔记(2):tf.nn.dropout 与 tf.layers.dropout
- 进程间通信-Queue
- 【Alpha】阶段第九次Scrum Meeting
- Codeforces Round #555 (Div. 3) D. N Problems During K Days 【数学思维】