题意:已知方程的根在0-1范围内,求解方程的根,如果方程不存在根,那就输出 no solution.

直接二分,保留四位小数.

#include "pch.h"
#include <string>
#include<iostream>
#include<map>
#include<memory.h>
#include<vector>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<math.h>
#include<iomanip> namespace cc
{
using std::cout;
using std::endl;
using std::cin;
using std::map;
using std::vector;
using std::string;
using std::sort;
using std::priority_queue;
using std::greater;
using std::vector;
using std::swap;
using std::stack; constexpr double MD = 1e-; double p, q, r, s, t, u; double cal(double x)
{
return
p * exp(-x) + q * sin(x) + r * cos(x) + s * tan(x)
+ t * x*x + u; } void solve()
{
while (cin >> p >> q >> r >> s >> t >> u)
{
double l = , r = ;
if (cal(l)*cal(r) > )
{
cout << "No solution" << endl;
continue;
}
while (r - l > MD)
{
double m = (l + r) / ;
if (cal(m)*cal(l) > )
l = m;
else
r = m;
} cout << std::setiosflags(std::ios::fixed) << std::setprecision() << l << endl;; } } }; int main()
{ #ifndef ONLINE_JUDGE
freopen("d://1.text", "r", stdin);
#endif // !ONLINE_JUDGE
cc::solve(); return ;
}

uva-10341-二分法的更多相关文章

  1. UVA 10341 Solve It 解方程 二分查找+精度

    题意:给出一个式子以及里面的常量,求出范围为[0,1]的解,精度要求为小数点后4为. 二分暴力查找即可. e^(-n)可以用math.h里面的exp(-n)表示. 代码:(uva该题我老是出现Subm ...

  2. UVa 10341 (二分求根) Solve It

    很水的一道题,因为你发现这个函数是单调递减的,所以二分法求出函数的根即可. #include <cstdio> #include <cmath> //using namespa ...

  3. uVa 714 (二分法)

    Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu   Description   Before th ...

  4. UVa 10341 - Solve It

    题目:给一个方程,求解方程的解.已给出解的范围,并且可知方程等号左侧的函数是递减的,可用二分法进行试探,直到得出给定误差范围内的解. #include <cstdio> #include ...

  5. UVa 10341 - Solve It【经典二分,单调性求解】

    原题: Solve the equation:         p*e-x + q*sin(x) + r*cos(x) + s*tan(x) + t*x2 + u = 0         where  ...

  6. UVA 10341 Solve It 二分

    题目大意:给6个系数,问是否存在X使得等式成立 思路:二分.... #include <stdio.h> #include <math.h> #define EEE 2.718 ...

  7. UVA 10341 二分搜索

    Solve the equation:p ∗ e−x + q ∗ sin(x) + r ∗ cos(x) + s ∗ tan(x) + t ∗ x2 + u = 0where 0 ≤ x ≤ 1.In ...

  8. 【数值方法,水题】UVa 10341 - Solve It

    题目链接 题意: 解方程:p ∗ e^(−x) + q ∗ sin(x) + r ∗ cos(x) + s ∗ tan(x) + t ∗ x^2 + u = 0 (0 <= x <= 1) ...

  9. UVa - 10341

    Solve the equation:p ∗ e ^−x + q ∗ sin(x) + r ∗ cos(x) + s ∗ tan(x) + t ∗ x ^2 + u = 02 + u = 0where ...

  10. UVA 10341.Solve It-二分查找

    二分查找 二分查找又称折半查找,优点是比较次数少,查找速度快,平均性能好:其缺点是要求待查表为有序表,且插入删除困难.因此,折半查找方法适用于不经常变动而查找频繁的有序列表.首先,假设表中元素是按升序 ...

随机推荐

  1. 无法连接到 OPC服务器[无此类接口支持(异常来自HRESULT:0x80004002(E_NOINTERFACE))]

    来源:https://stackoverrun.com/cn/q/10400663 无法连接到ABB Freelance OPC服务器[无此类接口支持(异常来自HRESULT:0x80004002(E ...

  2. mysql数据字典 如何生成?

    用phpMyAdmin查看表结构,点击 打印预览. &amp;lt;img src="https://pic3.zhimg.com/50/3205ff3bd3da067528f4c1 ...

  3. 解决nginx转发websocket报400错误

    解决nginx转发websocket报400错误 说明 由于个人服务器上面有多个项目,配置了二级域名,需要对二级域名进行转发,在转发工作这快采取了大名鼎鼎的nginx.在这之前所有的项目运行转发都没问 ...

  4. VMWare VSphere6.0的实验笔记

    在现有的一个vsphere6.0虚拟平台上环境下搭建一套VSphere环境平台. 任务1: 1.建立1个win2008主机,192.168.12.10.16Gram,40G硬盘1独立存储+150G硬盘 ...

  5. 解决socket交互的10048和10055错误的总结

    问题:60多路轮训的情况下,5分钟之后,现场报链接不上子进程的错误.绝大部分为海康设备   分析: 子进程的日志中 存在输入海康的解码库的错误,在子进程的对外dll中加日志发现,socket链接的时候 ...

  6. 学习笔记之NumPy

    NumPy — NumPy http://www.numpy.org/ NumPy is the fundamental package for scientific computing with P ...

  7. [UE4]限制杀人信息的显示数量

  8. [UE4]死亡后调整视角

    AddLocalOffset:本地坐标偏移. 脱离控制器操作 会影响“OnDie”方法里面的相机移动操作,而函数里面又不允许使用“Delay”方法,但可以使用“Set Timer By Functio ...

  9. vue 动态路由 Get传值

    main.js //2.配置路由 注意:名字 const routes = [ { path: '/home', component: Home }, { path: '/news', compone ...

  10. 关于daterangepicker的配置

    一开始接触daterangepicker搞得思路很乱,慢慢研究才了解一些,下面粘一个daterangepicker的基本配置,代码是来自网上某位大神的.我只是引荐过来的,加入了周和月的汉化. 在回调函 ...