题意:给出一个数让你求出等于这个数的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. Android Gradle Plugin指南(五)——Build Variants(构建变种版本号)

    原文地址:http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 6. Build Vari ...

  2. [部署Mantis]用Administrator注册新用户时设置密码

    伤不起的Mantis邮箱配置,在新的Mantis配置里面默认通过接收激活邮件来设定密码. 如果你Mantis邮箱配置OK的话一切OK,遇到我这样死活配不成功,网络上大神们众说纷纭,一一参照,无奈死伤无 ...

  3. TFS WorkItem Permission Setting

    TFS非常强大,但是权限设置确实非常的恶心复杂,这貌似是一切NB又傲慢的软件的通病. 那么,在哪里设置 WorkItem 的权限呢? 第一步: 第二步: 第三步,下面你将一目了然. 第四步,Share ...

  4. UI_UITabBarController

    建立控制器 // 普通控制器 GroupViewController *groupVC = [[GroupViewController alloc] init]; SecondViewControll ...

  5. 【Multiple backgrounds】用CSS3实现网页多重背景

    对于背景属性background-image大家应该已经很熟悉了,在CSS2中与它相关的属性还有background-repeat(设置背景是否重复及重复的方式).background-positio ...

  6. 使用ViewDragHelper打造属于自己的DragLayout(抽屉开关 )

    使用ViewDragHelper打造属于自己的DragLayout(抽屉开关 ) DrawLayout这个自己定义的空间非经常见.qq,网易新闻.知乎等等,都有这样的效果,那这样的效果是如何实现的呢? ...

  7. ubuntu添加默认路由才可以访问网络

  8. Godaddy ssl续费更新问题总结

    之前客户在Godaddy 上购买的ssl证书过期了,但客户续费后打开https时却提示证书过期了 进行Godaddy 后台看到证书确实是过期的 但在账户里也确实看到ssl续费成功了 猜想可能是ssl续 ...

  9. MySql无法远程登录以及IP被锁解决办法

    授权 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;Query OK, 0 rows aff ...

  10. [Node.js]28. Level 5: Express Server

    Now let's create an express server which queries out for this search term and just returns the json. ...