题意:给出一个数让你求出等于这个数的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. 【spring cloud】在spring cloud服务中,打包ms-core失败,报错Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE:repackage (default) on project

    在spring cloud服务中,有一个ms-code项目,只为所有的微服务提供核心依赖和工具类,没有业务意义,作为核心依赖使用.所以没有main方法,没有启动类. 在spring cloud整体打包 ...

  2. 初次使用SQL调优建议工具--SQL Tuning Advisor

    在10g中,Oracle推出了自己的SQL优化辅助工具: SQL优化器(SQL Tuning Advisor :STA),它是新的DBMS_SQLTUNE包. 使用STA一定要保证优化器是CBO模式下 ...

  3. SAE java应用读写文件(TmpFS和Storage)

    近期不少java用户都在提sae读写本地文件的问题,在这里结合TmpFS和Storage服务说说java应用应该如何读写文件TmpFS是一个供应用临时读写的路径,但请求过后将被销毁.出于安全考虑,sa ...

  4. 文件权限控制篇access alphasort chdir chmod chown chroot closedir fchdir fchmod fchown fstat ftruncate getcwd

    access(判断是否具有存取文件的权限) 相关函数 stat,open,chmod,chown,setuid,setgid 表头文件 #include<unistd.h> 定义函数 in ...

  5. CentOS 5.5 虚拟机安装 VirtualBox 客户端增强功能

    .启动安装在 VirtualBox 中的 CentOS 5.5 虚拟机,点击“设备” => “安装增强功能”.这个时候你就可以看到有一个“光盘”已经挂载到 CentOS 5.5 的桌面上了.它包 ...

  6. Linux 提权常用命令集

    转载:http://www.myhack58.com/Article/html/3/8/2017/83236.htm 0x00 操作系统相关 操作系统类型版本 cat /etc/issue cat / ...

  7. 【BZOJ】【2242】【SDOI2011】计算器

    快速幂/扩展欧几里得/BSGS 经典好例题!! 三个问题三种算法…… 算法:白书(算法竞赛入门经典——训练指南)全有…… /************************************** ...

  8. Cocos2dx 3.0 过渡篇(二十七)C++11多线程std::thread的简单使用(下)

    本篇接上篇继续讲:上篇传送门:http://blog.csdn.net/star530/article/details/24186783 简单的东西我都说的几乎相同了,想挖点深的差点把自己给填进去. ...

  9. vue设置多入口教程

    官方脚手架搭建vue项目 在src 目录下复制app内容创建test.vue,demo.vue, main.js复制main.js内容demo.js,test.js,修改一下内容 在根目录下创建tes ...

  10. iOS开发-Get请求,Post请求,同步请求和异步请求

    标题中的Get和Post是请求的两种方式,同步和异步属于实现的方法,Get方式有同步和异步两种方法,Post同理也有两种.稍微有点Web知识的,对Get和Post应该不会陌生,常说的请求处理响应,基本 ...