Can you solve this equation?---hdu2199(二分)
http://acm.hdu.edu.cn/showproblem.php?pid=2199
给出y的值求x;
8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 = Y
x是0到100的实数所以要用二分的方法;
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
#define N 110
#define INF 0xffffff int main()
{
int T,flag;
double y, m, L, R, Mid;
scanf("%d", &T);
while(T--)
{
scanf("%lf", &y);
m=*pow(,)+*pow(,)+*pow(,)+*+;
if(m<y||y<)
{
printf("No solution!\n");
continue;
}
L=;R=;
while(L<=R)
{
Mid=(L+R)/;
m=*pow(Mid,)+*pow(Mid,)+*pow(Mid,)+*Mid+;
if(fabs(m-y)<0.0001)
{
flag=;
break;
}
else if(m>y)
{
R=Mid;
}
else
{
L=Mid;
}
}
if(flag==)
printf("%.4lf\n", Mid);
else
printf("No solution!\n");
}
return ;
}
Can you solve this equation?---hdu2199(二分)的更多相关文章
- 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?(高精度二分)
http://acm.hdu.edu.cn/howproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 MS ...
- Can you solve this equation?(二分)
Can you solve this equation? Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Ja ...
- HDU 2199 Can you solve this equation?【二分查找】
解题思路:给出一个方程 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,求方程的解. 首先判断方程是否有解,因为该函数在实数范围内是连续的,所以只需使y的值满足f(0)< ...
- Day3-K-Can you solve this equation? HDU2199
Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and ...
- hdoj 2199 Can you solve this equation? 【二分枚举】
题意:给出一个数让你求出等于这个数的x 策略:如题. 由于整个式子是单调递增的.所以能够用二分. 要注意到精度. 代码: #include <stdio.h> #include <s ...
- 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 ( ...
随机推荐
- erlang的小知识,未分类。
erlang:module_loaded(module):检测模块是否已加载:
- c++ vector init操作
1) string str[n]={"hello", ...}; vector<string> strArray(str,str+n); 2) vector<st ...
- 启动vsftpd失败
启动vsftpd失败 在使用centos时, 要用ftp上传文件, 但是一到脚本的ftp命令就会出错: rpm -Uvh http://mirror.centos.org/centos/6/os/i3 ...
- NPOI帮助类(Excel转DataTable、DataTable转Excel)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using NPOI.SS. ...
- 刚刚完成了在vs2013中通过 ef连接mysql数据库的工作。感觉没有想象中的简单。试了n次终于成功。故记录成功的方法,希望可以帮到大家
分两种情况,如果你是用entity framework 5.0的时候 mysql-connector-net的版本不是很重要. MySQL For VisualStudio的版本也不重要 (这个不装就 ...
- maven 配置多模块项目 pom modules
所有用Maven管理的真实的项目都应该是分模块的,每个模块都对应着一个pom.xml.它们之间通过继承和聚合(也称作多模块,multi-module)相互关联.那么,为什么要这么做呢?我们明明在开发一 ...
- mysql中什么是逻辑备份
需求描述: mysql中,或者说关系型数据库中逻辑备份到底指的是什么呢,主要还是对于 概念的理解,在此记录下. 概念解释: 逻辑备份:主要指的是保存数据库的逻辑结构(比如:create dattaba ...
- mysql中,root用户密码被遗忘,该如何进行重置?
需求描述: 在mysql的测试环境中,有时候会遇到一段时间之后root用户的密码被遗忘的情况, 这个时候,就是需要对root密码进行重置,不过,在生产环境中,这种情况还是很少见. 环境描述: 操作系统 ...
- opencascade读取iges并用vtk离散的一些问题
近期抽时间在弄iges文件内容读取的工作.然后将其离散化在vtk中能够显示处理以及兴许的一些工作.主要目的是识别CAD文件导出的模型,然后进行离散处理.方便兴许的处理.离散工作比較简单.opencas ...
- 实现Runnable接口和继承Thread类区别
如果一个类继承Thread,则不适合资源共享.但是如果实现了Runable接口的话,则很容易的实现资源共享. 实现Runnable接口比继承Thread类所具有的优势: 1):适合多个相同的程序代码的 ...