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. 208. Implement Trie (Prefix Tree)

    题目: Implement a trie with insert, search, and startsWith methods. 链接: http://leetcode.com/problems/i ...

  2. Android Spannable

    ApiDemo 源码至 com.example.android.apis.text.Link 类. 首先,看一下其运行效果: 要给 TextView 加上效果,方式主要有几种: 第一种,自动应用效果, ...

  3. How to download a website for offline usage

    wget -U Mozilla --recursive --no-clobber --page-requisites --html-extension --convert-links -- restr ...

  4. Unable to open c

    1. Unable to open c:\Cadence\PSD_14.2\tools\capture\allegro.cfg for reading. Please correct the abov ...

  5. devfs,proc,udev

    devfs:常用的驱动函数封装 proc:在用户态检查内核状态的机制 udev 和 devfs相比? 一个是用户空间里的,一个运行在内核空间且被2.6以后版本抛弃了

  6. 不只是技术!成为IT经理必备的十大软技能

    摘要:可能你是一名普通的IT从业员,一个小小的程序员,可随着社会的发展和科技的进步,对人才的要求越来越高,你可能通过技术获得了职位,但你若想升职加薪却少不了软技能:谈判技巧.积极倾听.演讲技巧以及领导 ...

  7. Java开发之多线程下载和断点续传

    代码实现了多线程下载和断点续传功能 import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream ...

  8. sublime text2卸载和重新安装

    很多同学使用 sublime text2 的时候,出现一些奇怪的bug,且重启无法修复. 于是,就会想到卸载 sublime text2 再重新安装. 然而,你会发现,重新安装后,这个bug任然存在, ...

  9. 1022. Genealogical Tree(topo)

    1022 简单拓扑 不能直接dfs 可能有不联通的 #include <iostream> #include<cstdio> #include<cstring> # ...

  10. poj2352

    纪念树状数组初步(……): 这题已经给了y升序,y相同时x升序,(yeah) 所以容易想到O(n^2)的模拟算法: 其实分析一下就是对于当前xi,统计之前有多少个小于等于xi(因为已经保证了没有相同坐 ...