题意:给出一个数让你求出等于这个数的x

策略:如题。

由于整个式子是单调递增的。所以能够用二分。

要注意到精度.

代码:

#include <stdio.h>
#include <string.h>
#include <math.h>
#define eps 1e-10
#define f(x) 8*pow(x, 4) + 7*pow(x, 3) + 2*pow(x, 2) + 3*x
int main()
{
int t;
double n;
scanf("%d", &t);
while(t --){
scanf("%lf", &n);
n-=6;
double max = f(100);
if(n<0||n>max){
printf("No solution!\n");
continue;
}
double left, right, mid;
left = 0; right = 100;
while(right-left > 1e-7){ //精度要小于1e-7。
mid = (left+right)/2;
double temp = f(mid);
if(temp < n) left = mid+1e-7;
else right = mid;
}
printf("%0.4lf\n", left);
}
return 0;
}

hdoj 2199 Can you solve this equation? 【二分枚举】的更多相关文章

  1. 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 == ...

  2. hdoj 2199 Can you solve this equation?【浮点型数据二分】

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  3. HDU 2199 Can you solve this equation? (二分 水题)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  4. HDU - 2199 Can you solve this equation? 二分 简单题

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  5. hdu 2199 Can you solve this equation? 二分

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  6. Hdoj 2199.Can you solve this equation? 题解

    Problem Description Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solutio ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 转: gob编解码

    要让数据对象能在网络上传输或存储,我们需要进行编码和解码.现在比较流行的编码方式有JSON,XML等.然而,Go在gob包中为我们提供了另一种方式,该方式编解码效率高于JSON.gob是Golang包 ...

  2. 在windows上搭建C语言开发环境——借助eclipse和MinGW

    0. 前言     [本文目的]     近期在电脑上又一次安装了MinGW,发现MinGW的安装方法和之前的方法稍有差别,全部再写了一篇博文记录一下具体的安装方法.     [本文主要内容]     ...

  3. strdup实现

    char * strdup(char *str) { char * strNew; assert(str != NULL); strNew = (); strcpy(strNew,str); retu ...

  4. strncpy实现

    #include<stdio.h> char *my_strncpy(char *dest,char *src,int n) { int i; ;i<n && src ...

  5. 在Mac OS X上配置Apache2

    转载:http://www.cnblogs.com/yuanyq/p/3435022.html#2821339 最近一段时间在开发面向移动设备的网页,而且是静态网页.所以很需要一个HTTP服务器,简单 ...

  6. C语言:通过指针函数输出二维数组中每个学生的成绩

    // //  main.c //  Pointer_function // //  Created by ma c on 15/8/2. //  Copyright (c) 2015年 bjsxt. ...

  7. Java按键事件KeyEvent

    按键事件可以利用键盘来控制和执行一些动作,或者从键盘上获取输入,只要按下,释放一个键或者在一个组件上敲击,就会触发按键事件.KeyEvent对象描述事件的特性(按下,放开,或者敲击一个键)和对应的值. ...

  8. Cisco KVM Console无法打开

    前阵子手贱, 每次弹出的Java的update的对话框我都是直接关闭的, 那天实在是不忍再受骚扰, 升级到了Java 8. 结果Cisco的KVM就死活打不开了, 报错如下: Exception: c ...

  9. Dropwizard框架入门

    最近项目用到了Dropwizard框架,个人感觉还不错,那么这里就从他们官网入手,然后加上自己的实现步骤让大家初步了解这个框架. 官网对DW(Dropwizard)的定义是跨越了一个库和框架之间的界限 ...

  10. JS中应用正则表达式转换大小写

    JS中应用正则表达式转换大小写,代码很简单,看代码: 以下首字母大写,其它字母小写 <script type="text/javascript"> function r ...