题意:已知方程的根在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. 利用Mega2560实现USB转串口

    1. 介绍 2560的串口一共有4个,分别对应数字接口0-1,18-19,16-17,14-15所有串口都可以跟pc通信,但只有0-1是跟板子上的usb2ttl连接,电脑上显示的串口编号就是0-1对应 ...

  2. SD-SDI播出系统---使用GTX TX产生恢复时钟

    SD-SDI播出系统---使用GTX TX产生恢复时钟 1. 2.SD-SDI恢复时钟的生成

  3. 认识数据-数据的计量尺度(Levels of Measurement)

    一. 数据的计量尺度(Levels of Measurement) 一般认为,数据是对客观现象计量的结果.按照对事物计量的精确程度,可将所采用的计量尺度由低级到高级分为四个层次: 1.定类尺度(Nom ...

  4. Console下Pause效果的函数

    function PauseConsole(Prompt: PAnsiChar): boolean;var  hStdIn, hStdOut: THandle;  dwRd, dwWr, i: Car ...

  5. 前端之js-echarts组件介绍

    Echarts.init: 全局 echarts 对象,在 script 标签引入 echarts.js 文件后获得,或者在 AMD 环境中通过 require('echarts') 获得. < ...

  6. Java第08次实验提纲(多线程)

    PTA与参考资料 题集:多线程 多线程实验参考文件 ThreadReading 实验-基础部分 基础题目MyThread类.PrintTask(讲解线程Thread与任务Runnable相分离的概念) ...

  7. 测试教程网.unittest教程.8. 断言异常

    From: http://www.testclass.net/pyunit/assert_raise/ 背景 我们有时候需要断言一些方法会抛出异常,这些异常需要符合我们的预期. 代码 新建test_e ...

  8. mysql 数据库排序规则

    MySQL中的排序规则.在新建MySQL数据库或表的时候经常会选择字符集和排序规则.数据库用的字符集大家都知道是怎么回事,那排序规则是什么呢? 排序规则:是指对指定字符集下不同字符的比较规则.其特征有 ...

  9. 解决搜狗高速模式及设置页面打不开的问题DisableFeature.reg

    搜狗浏览器安装问题1.安装的时候要选择自定义安装,去掉参加用户体验计划的√,否则可能安装不上.2.搜狗sogou_explorer_7.0_0111.exe,设置页面se://settings/?ca ...

  10. STL基础--容器

    容器种类 序列容器(数组,链表) Vector, deque, list, forward list, array 关联容器(二叉树),总是有序的 set, multiset根据值排序,元素值不能修改 ...