UVa - 12050 Palindrome Numbers (二分)
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
题意:给出一个方程,求解X;
思路:因为方程是单调递减的,所以二分求解;
#include<iostream>
#include<cstdio>
#include<cmath>
#define EPS (10e-8)
using namespace std;
double p,q,r,s,t,u;
inline double fomula(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)!=EOF){
double left=, right=, mid;
bool flag=false;
if(fomula(left)*fomula(right) > ){
printf("No solution\n");
continue;
}
while(right-left > EPS){
mid = (left+right)/;
if(fomula(mid)*fomula(left) > ) left=mid;
else right=mid;
} printf("%.4f\n", mid);
}
return ;
}
UVa - 12050 Palindrome Numbers (二分)的更多相关文章
- Uva - 12050 Palindrome Numbers【数论】
题目链接:uva 12050 - Palindrome Numbers 题意:求第n个回文串 思路:首先可以知道的是长度为k的回文串个数有9*10^(k-1),那么依次计算,得出n是长度为多少的串,然 ...
- POJ2402/UVA 12050 Palindrome Numbers 数学思维
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example,the ...
- UVa 12050 - Palindrome Numbers (回文数)
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, th ...
- UVA 12050 - Palindrome Numbers 模拟
题目大意:给出i,输出第i个镜像数,不能有前导0. 题解:从外层开始模拟 #include <stdio.h> int p(int x) { int sum, i; ;i<=x;i+ ...
- UVa 10006 - Carmichael Numbers
UVa 10006 - Carmichael Numbers An important topic nowadays in computer science is cryptography. Some ...
- Palindrome Numbers(LA2889)第n个回文数是?
J - Palindrome Numbers Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu ...
- 2017ecjtu-summer training #1 UVA 12050
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, th ...
- UVa - 12050
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example,the ...
- UVA.136 Ugly Numbers (优先队列)
UVA.136 Ugly Numbers (优先队列) 题意分析 如果一个数字是2,3,5的倍数,那么他就叫做丑数,规定1也是丑数,现在求解第1500个丑数是多少. 既然某数字2,3,5倍均是丑数,且 ...
随机推荐
- JS从键盘输入当月利润,求应发放奖金总数
题目:企业发放的奖金根据利润提成.利润(I)低于或等于10万元时,奖金可提10%:利润高 于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提 成7.5%:20万到4 ...
- C# 多线程之通过Timer开启线程的例子
本例通过Timer的tick()方法触发TimerCallback委托来开辟新的线程,线程中的具体工作通过一个静态方法作为参数给TimerCallback委托. using System; using ...
- android 华为、魅族手机无法打印 Log 日志的问题
最近使用魅族真机测试 App 时,发现 LogCat 不显示项目工程中通过Log.d()和Log.v()打印的 debug 和 verbose 级别的日志,甚是奇怪,通过 debug 模式断点调试也没 ...
- 基于SSM开发学生信息管理系统源码
开发环境: Windows操作系统开发工具: Eclipse+Jdk+Tomcat+MySql数据库 运行效果图 源码及原文链接:https://javadao.xyz/forum.php?mo ...
- [PHP] 使用PHP在mongodb中进行嵌套查询
作为文档数据库,数据库中存储的数据是类似json的结构,比如{“modelInfo”:{"status":1,audited:"1"}},想要查询status是 ...
- webpack打包进行丑化压缩遇到(TypeError Cannot read property 'compilation' of undefined)问题
今天再重新配置老项目node打包环境的时候遇到了一个问题. 在打包的时候报: TypeError: Cannot read property 'compilation' of undefined 错误 ...
- 广度优先搜索BFS---求出矩阵中“块”的个数
题目: 给出一个 m x n 的矩阵,矩阵中的元素为0或1.如果矩阵中有若干个 1是相邻的,那么称这些1构成了一个“块”.求给定的矩阵中“块”的个数. 0 1 1 1 0 0 1 0 0 1 0 0 ...
- checkbox 样式重写
css样式 .me-checkbox:checked { background: #1673ff } .me-checkbox { outline: none;/*轮廓*/ width: 25px; ...
- Mac 终端 Tomcat 环境配置过程
Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache.Sun 和其他一些公司及个人共同开发而成.Tomc ...
- CentOS7安装Python3.6.8
1.首先通过yum安装python可能用到的依赖 yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel ...