Day3-K-Can you solve this equation? HDU2199
Now please try your lucky.
InputThe 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);OutputFor 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! 思路:二分查找答案问题,设置精度后直接查找即可,代码如下:
double Y;
double check(double x) {
return * (x * x * x * x) + * (x * x * x) + * (x * x) + * x + ;
}
int main() {
int T;
scanf("%d", &T);
while(T--) {
double l = 0.0, r = 100.0, mid;
scanf("%lf", &Y);
if(check(0.0) > Y || check(100.0) < Y) {
printf("No solution!\n");
continue;
}
while(r - l > 1e-) {
mid = (r + l) / 2.0;
if(check(mid) - Y > )
r = mid;
else
l = mid;
}
printf("%.4lf\n", mid);
}
return ;
}
Day3-K-Can you solve this equation? HDU2199的更多相关文章
- Can you solve this equation?---hdu2199(二分)
http://acm.hdu.edu.cn/showproblem.php?pid=2199 给出y的值求x: 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 = Y x是0到100的 ...
- 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 ...
- hdu 2199 Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- hdu 2199:Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- 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 ...
- HDU 2199 Can you solve this equation? (二分 水题)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- hdoj 2199 Can you solve this equation?【浮点型数据二分】
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- Can you solve this equation?
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- HDU 2199 Can you solve this equation(二分答案)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
随机推荐
- 引入C/C++动态库
[DllImport("SocketAPI.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = t ...
- ConcurrentHashMap 实现缓存类
参考:https://blog.csdn.net/woshilijiuyi/article/details/81335497 在规定时间内,使用 hashMap 实现一个缓存工具类,需要考虑一下几点 ...
- 虚拟机设置固定IP从而使同一局域网可以访问
没有ifcfg-eth0 时:https://www.cnblogs.com/itboxue/p/11186910.html (1)关机,将网络模式设置成桥接模式 (2)开机 进入 cd /etc/s ...
- 19市赛 树状数组 第k个小的糖果
int find_kth(int k) { , cnt = , i; ; i >= ; i--)/ { ans += ( << i); if (ans >= maxn|| cn ...
- JS清除空格之trim()方法
JQ: $.trim() 函数用于去除字符串两端的空白字符. 注意:$.trim()函数会移除字符串开始和末尾处的所有换行符,空格(包括连续的空格)和制表符.如果这些空白字符在字符串中间时,它们将被保 ...
- 洛谷P1301 魔鬼之城 题解
想找原题请点击这里:传送门 题目描述 在一个被分割为N*M个正方形房间的矩形魔鬼之城中,一个探险者必须遵循下列规则才能跳跃行动.他必须从(, )进入,从(N, M)走出:在每一房间的墙壁上都写了一个魔 ...
- 【Javaweb】Servlet的xml和注解配置
1.xml <%@ page language="java" contentType="text/html;" %> <!DOCTYPE ht ...
- 8.1.1默认的map函数、reduce函数、分区函数
1.1.1 默认的map函数和reduce函数 (1)Maper和Reuducer默认类 如果没有指定maper类和reduce类,则会用默认的Maper和Reuducer类去处理数据 ...
- ubuntu开启mysql远程连接,并开启3306端口
mysql -u root -p 修改mysql库的user表,将host项,从localhost改为%.%这里表示的是允许任意host访问,如果只允许某一个ip访问,则可改为相应的ip mysql& ...
- PTA的Python练习题(六)
从 第3章-8 字符串逆序 开始 1. n = str(input()) n1=n[::-1] print(n1) 2. 不是很好做这道题,自己还是C语言的思维,网上几乎也找不到什么答案 s = in ...