hdu 2199 Can you solve this equation?(二分法求多项式解)
题意
给Y值,找到多项式 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y 在0到100之间的解。
思路
从0到100,多项式是单调的,故用二分法求解。
代码
double calc(double x){
return 8*x*x*x*x+7*x*x*x+2*x*x+3*x+6;
}
int main(){
int T;
cin>>T;
while(T--){
double Y;
cin>>Y;
double L,R;
L = 0.0, R= 100.0;
if(calc(L)>Y || Y>calc(R)){
cout<<"No solution!"<<endl;
}else{
double mid;
while((R-L)>(1e-10)){
mid = (L+R) / 2;
if(calc(mid)>Y){
R = mid;
}else{
L = mid;
}
}
mid = (R+L)/2;
printf("%.4lf\n",mid);
}
}
return 0;
}
hdu 2199 Can you solve this equation?(二分法求多项式解)的更多相关文章
- hdu 2199 Can you solve this equation? (二分法)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU 2199 Can you solve this equation?(二分精度)
HDU 2199 Can you solve this equation? Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == ...
- hdu 2199 Can you solve this equation?(高精度二分)
http://acm.hdu.edu.cn/howproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 MS ...
- HDU 2199 Can you solve this equation?(二分解方程)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/10 ...
- hdu 2199:Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- ACM:HDU 2199 Can you solve this equation? 解题报告 -二分、三分
Can you solve this equation? Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Su ...
- hdu 2199 Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU 2199 Can you solve this equation? (二分 水题)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU 2199 Can you solve this equation(二分答案)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- HDU - 2199 Can you solve this equation? 二分 简单题
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
随机推荐
- 安卓使用讯飞sdk报错
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.iflytek.cloud.SpeechSy ...
- python循环以及控制语句
python流程 学习完本篇,你将会通过python完成以下题目 试利用break语句求解2-100之间的素数. (1)素数是指除了能被1和它本身整除外,不能被其它数所整除的数.判断一个自然数是否是素 ...
- PHP中命名空间是怎样的存在?(二)
今天带来的依然是命名空间相关的内容,本身命名空间就是PHP中非常重要的一个特性.所以关于它的各种操作和使用还是非常复杂的,光使用方式就有很多种,我们一个一个的来看. 子命名空间 命名空间本身就像目录一 ...
- 队列,一种"公平"的数据结构
路过一家奶茶店,由于生意火爆,门口的排着长长的队伍,先排队的人先买到奶茶,然后再轮到下一个,秩序井然.有没有一种数据结构能体现"先来后到"这种顺序呢? 当然有,那就是队列.先看一下 ...
- Shell系列(38)- 数组操作→取值、遍历、替换、删除
引言 在Linux平台上工作,我们经常需要使用shell来编写一些有用.有意义的脚本程序.有时,会经常使用shell数组.那么,shell中的数组是怎么表现的呢,又是怎么定义的呢?接下来逐一的进行讲解 ...
- Kubernetes-Pod介绍(四)-Deployment
前言 本篇是Kubernetes第七篇,大家一定要把环境搭建起来,看是解决不了问题的,必须实战. Kubernetes系列文章: Kubernetes介绍 Kubernetes环境搭建 Kuberne ...
- YbtOJ#853-平面标记【整体二分,凸壳】
正题 题目链接:http://www.ybtoj.com.cn/contest/119/problem/3 题目大意 给出\(n\)个点\((x_i,y_i)\),\(m\)次给出\((k_i,a_i ...
- mimikatz使用笔记
一.获取密码# privilege::debug sekurlsa::logonpasswords mimikatz.exe "sekurlsa::debug" "sek ...
- 14-Java锁的概述
14-锁的概述 乐观锁与悲观锁 乐观锁与悲观锁是数据库中引入的名词,但是在并发包里也引入了类似的思想,在这里我们还是有必要需要了解一下. 悲观锁指数据被外界修改持保守态度,认为数据会很容易被其 ...
- java课堂测试2第一阶段:方法运用
package test2; import java.util.*; public class Test2 { public static int generateRandom(int fanwei) ...