http://acm.hdu.edu.cn/howproblem.php?pid=2199

Can you solve this equation?

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

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!
 
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define N 100010 using namespace std; int main()
{
int t, y;
double low, high, mid, k, x1, x2;
scanf("%d", &t);
while(t--)
{
scanf("%d", &y);
low = ;
high = ;
x1 = * pow(, ) + * pow(, ) + * pow(, ) + * + ;
x2 = * pow(, ) + * pow(, ) + * pow(, ) + * + ;
if(x1 <= y && y <= x2)
{
while(high - low > 1e-)/*注意1e-7*/
{
mid = (low + high) / ;
k = * pow(mid, ) + * pow(mid, ) + * pow(mid, ) + * mid + ;
if(k > y)
high = mid - 1e-;
else if(k < y)
low = mid + 1e-;
}
printf("%.4f\n", 1.0 * (low + high) / );
}
else
printf("No solution!\n"); }
return ;
}

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?【二分查找】

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

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

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

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

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

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

  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? (二分 水题)

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

  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. 听说noip2015有幻方

    终于可以说一句:pascal大法好了 magic.pp是写好的算幻方哦…… 虽然这种水题大家都会,也没什么卵用……

  2. 移动WebApp开发框架(珍藏)

     1.Jquery Mobilehttp://demos.jquerymobile.com/1.4.5/button-markup/http://andymatthews.net/code/jQuer ...

  3. Chrome 快捷键使用

    窗口和标签页快捷方式 Ctrl+N 打开新窗口 按住 Ctrl‎ 键,然后点击链接 在新标签页中打开链接 按住 Shift 键,然后点击链接 在新窗口中打开链接 Alt+F4 关闭当前窗口 Ctrl+ ...

  4. Sqlite数据库 找不到请求的 .Net Framework Data Provider。可能没有安装

      解决方法 在web.config里面添加 <system.data> <DbProviderFactories> <remove invariant="Sy ...

  5. spring security的标签库

    应用标签库:<%@ taglib prefix='security ' uri='http://www.springframework.org/security /tags' %> < ...

  6. Android RecyclerView使用详解(二)

    在上一篇(RecyclerView使用详解(一))文章中简单的介绍了RecyclerView的基本用法,接下来要来讲讲RecyclerView的更多用法,要实现不同的功能效果,大部分都还是在于Recy ...

  7. unity, setting standard shader by script

    http://forum.unity3d.com/threads/change-standard-shader-render-mode-in-runtime.318815/

  8. Javascript的匿名函数

    一.什么是匿名函数?在Javascript定义一个函数一般有如下三种方式:函数关键字(function)语句:function fnMethodName(x){alert(x);}函数字面量(Func ...

  9. IIS6到7,web.config的配置

    如果在IIS6中你的web.config中是以下配置: 这是在IIS6中我们习惯的经典模式的配置 < system.web>  " " " " &q ...

  10. Cocos2d-x FlappyBird

    HelloWorldScene.cpp #include "HelloWorldScene.h" USING_NS_CC; CCScene* HelloWorld::scene() ...