Solve the equation:
p ∗ e
−x + q ∗ sin(x) + r ∗ cos(x) + s ∗ tan(x) + t ∗ x
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,1]就好了

//meek///#include<bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include<iostream>
#include<bitset>
using namespace std ;
#define mem(a) memset(a,0,sizeof(a))
#define pb push_back
#define fi first
#define se second
#define MP make_pair
typedef long long ll; const int N = ;
const int inf = 0x3f3f3f3f;
const int MOD = ;
const double eps = 0.000001; double q,p,r,s,t,u,a,b;
double check(double x) {
return p * exp(-x) + q * sin(x) + r * cos(x) + s * tan(x) + t * x * x + u;
}
int main() {
while(~scanf("%lf%lf%lf%lf%lf%lf",&p,&q,&r,&s,&t,&u)) {
double a = 0.0,b = 1.0;
if(check(a) * check(b) > ) {
printf("No solution\n");continue;
}
else if(fabs(check(0.0)) <= eps){
printf("0.0000\n");continue;
}
else if(fabs(check(1.0)) <= eps) {
printf("1.0000\n");continue;
}
if(check()>) {
a = 1.0;
b = 0.0;
}
else {
b = 1.0;
a = 0.0;
}
while() {
double x = (a+b)/;
double temp = check(x);
if(fabs(temp) <= eps) {
printf("%.4f\n",x);
break;
}
else if(temp > ) {
b = x;
}
else a = x;
}
}
return ;
}

代码

UVA 10341 二分搜索的更多相关文章

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

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

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

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

  3. UVA 10341 Solve It 二分

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

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

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

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

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

  6. UVa 10341 - Solve It

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

  7. UVa - 10341

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

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

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

  9. [LeetCode] Largest BST Subtree 最大的二分搜索子树

    Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest mea ...

随机推荐

  1. 代码文档生成工具-Doxygen生成CHM和RTF图文教程

    Doxygen是一种开源跨平台的,以类似JavaDoc风格描述的文档系统,可以从一套归档源文件开始,生成chm格式的文档.本文主要讲解如何在winddows下安装doxygen.     1.下载do ...

  2. python数组的使用

    python数组的使用 2010-07-28 17:17 1.Python的数组分三种类型:(1) list 普通的链表,初始化后可以通过特定方法动态增加元素.定义方式:arr = [元素] (2) ...

  3. Enyim.Caching 客户端配置及示例

    一.工作准备 memcached客户端:Enyim.Caching.2.13 memcached服务器:memcached-win64-1.4.4-14 备注:不建议使用windows服务器,开发环境 ...

  4. 单点登录 关于Cookie跨域的问题

    public void ProcessRequest(HttpContext context) { HttpCookie cookie = new HttpCookie("name" ...

  5. iOS10推送必看UNNotificationServiceExtension

    转:http://www.cocoachina.com/ios/20161017/17769.html (收录供个人学习用) iOS10推送UNNotificationServic 招聘信息: 产品经 ...

  6. VDN For PB Web实现消息推送

    利用VesnData.Net(VDN)的互联网数据驱动功能我们实现了PB连接互联网数据库的功能.在互联网开发的过程中我们往往有些消息或者数据希望即时能够通知到各个客户端,现在比较流行的一种技术就是消息 ...

  7. asp.net自带的异步刷新控件使用

    一直都是使用jquery的$.ajax,由于刚刚加入的公司是用asp.net的,webform与之前的ajax加在一起显得很混乱,后来发现asp.net已经封装了一下ajax功能,就查了一下,并且做了 ...

  8. Notes of the scrum meeting(12.5)

    meeting time:18:00~18:30p.m.,December 5th,2013 meeting place:3号公寓一层 attendees: 顾育豪                   ...

  9. JS多种方法实现随机颜色;

    JS随机颜色有很多地方要用到:比如大家看到很多标签连接都是五颜六色.实现随机颜色的方法有多种,下面来看看具体的实现代码: 方法一: var getRandomColor = function() { ...

  10. 断点续传 (HTTP) 归纳

    由于最近项目中要上传较大的文件,基于公司原有的底层框架的局限性,对于大文件的传输都束手无策,基于文件传输的安全性,考虑用断点续传(HTTP)以及FTP上传两种方式实现下面归纳下HTTP续传和FTP上传 ...