Can you solve this equation?

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6023    Accepted Submission(s): 2846

Problem Description
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 100;

Now please try your lucky.
 
Input
The first line of the input contains an integer T(1<=T<=100) which means the number of test cases. Then T lines follow, each line has a real number Y (fabs(Y) <= 1e10);
 
Output
For each test case, you should just output one real number(accurate up to 4 decimal places),which is the solution of the equation,or “No solution!”,if there is no solution for the equation between 0 and 100.
 
Sample Input
2
100
-4
 
Sample Output
1.6152
No solution!
 
Author
Redow
 

一道初学者的二分题,讲课用

#include <iostream>
#include <cstdio>
using namespace std; double y; double getfx(double x){
return 8*x*x*x*x + 7*x*x*x + 2*x*x + 3*x + 6;
} void computing(){
if(getfx(100)<y-1e-3 || getfx(0)>y+1e-3){
printf("No solution!\n");
return;
}
double l=0,r=100;
while(r-l>1e-6){
double mid=(l+r)/2;
if(getfx(mid)>y) r=mid;
else l=mid;
}
printf("%.4lf\n",r);
} int main(){
int t;
scanf("%d",&t);
while(t-- >0){
scanf("%lf",&y);
computing();
}
return 0;
}

HDU 2199 Can you solve this equation? (二分 水题)的更多相关文章

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

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

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

  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?(高精度二分)

    http://acm.hdu.edu.cn/howproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 MS ...

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

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

  7. HDU 2199 Can you solve this equation(二分答案)

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

  8. HDU 2199 Can you solve this equation?【二分查找】

    解题思路:给出一个方程 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,求方程的解. 首先判断方程是否有解,因为该函数在实数范围内是连续的,所以只需使y的值满足f(0)< ...

  9. hdu 2199 Can you solve this equation?(二分搜索)

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

随机推荐

  1. php Laravel windows安装

    先要装一个composer, 如果不会装请看这里composer windows可以直接下载composer-setup.exe, 如果安装失败提示"Unable to connect to ...

  2. POJ2531——Network Saboteur(随机化算法水一发)

    Network Saboteur DescriptionA university network is composed of N computers. System administrators g ...

  3. poj3月题解

    poj2110 二分答案+bfs判定 poj2112 二分答案+最大流判定(二分答案真乃USACO亲儿子) poj1986 裸的LCA,值得注意的是,树中任意两点的距离可以等于这两点到根的距离减去2* ...

  4. NOI2002robot

    这题又是纯数论题…… 独立数就是欧拉函数,政客和军人的含义已经说的很清楚了,学者是最多的…… 首先,如果我们知道了政客和军人的答案,那就只要用n的所有因子的欧拉函数值减去这两个值,然后取模就行了. 但 ...

  5. mysql slave 错误解决

    执行CHANGE MASTER TO master_host............后报错 ERROR 1201 (HY000): Could not initialize master info s ...

  6. Clear All of Them I(HDU 3920状压dp)

    题意:给有2*n个敌人的位置,枪在(0,0)位置,一次能消灭两个敌人,耗费能量为枪到一个敌人,由这个敌人再到另个敌人的的距离和,求消灭所有敌人最小耗费能量. 分析:一次枚举状态的两位即可 #inclu ...

  7. QTP安装和破解

    (1)底版本QTP安装破解 安装:http://bbs.51testing.com/thread-527025-1-1.html 进行破解: 1.创建文件夹C:/Program Files/Commo ...

  8. 第一个GTK+程序

    在这一章节中,我们将开始编写第一个GTK+程序. 超级简单的例子 我们要“制造”一个超级简单的GTK+程序.就是显示一个空白的窗口. #include <gtk/gtk.h> int ma ...

  9. bzoj 2815 [ZJOI2012]灾难(构造,树形DP)

    [题意] 求把每个点删除后,不可达点的数目. [思路] 构造一棵“灭绝树”,要求这棵树满足如果删除根节点后则该子树内的所有结点都不可达.则答案为子树大小-1. 如何构造这棵“灭绝树”? 将原图拓扑排序 ...

  10. MVC Razor 语法(转)

    http://blog.csdn.net/pasic/article/details/7072340 原文地址:MVC Razor 语法(转)作者:panzhaowen_jacki 语法名称 Razo ...