hdu Can you solve this equation?
本题是一道二分的题,核心就是mi的大小,即精度的取值。因为原函数是一个单调递增的函数,所以可以确定y的取值范围,并且在范围内的每一个y的值,一定至少存在一个x与其对应。刚开始我将取二分这个环节用一个函数来表示的,但是返回值始终是一个随机值,实在是搞不懂,无奈之下只能将那个步骤直接写在主函数内。。。
#include"iostream"
#include"stdio.h"
#include"algorithm"
#include"string.h"
#include"cmath"
#define mi 1e-8
using namespace std;
double cf(double x)
{
return *x*x*x*x + *x*x*x + *x*x + *x + ;
}
int main()
{
int t;
cin>>t;
while(t--)
{
double y;
cin>>y;
if(y< || y>)
{
printf("No solution!\n");
continue;
}
double x1=0.0,x2=100.0;
while(x2-x1>mi)
{
double x=(x2+x1)/2.0;
if(cf(x)>y) x2=x;
else x1=x;
}
printf("%.4lf\n",x1);
}
return ;
}
hdu Can you solve this equation?的更多相关文章
- 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?(二分精度)
HDU 2199 Can you solve this equation? Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == ...
- 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 ...
- 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? (二分 水题)
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? 二分 简单题
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
随机推荐
- 21.左旋转字符串[LeftRotateString]
[题目] 定义字符串的左旋转操作:把字符串前面的若干个字符移动到字符串的尾部.如把字符串AB1234 左旋转2位得到字符串1234AB.请实现字符串左旋转的函数.要求时间对长度为n的字符串操作的复杂度 ...
- percona-xtrabackup备份mysql
title: 1.percona-xtrabackup备份mysql date: 2016-04-10 23:19:12 tags: mysql categories: mysql --- 一.per ...
- Ubuntu的一些常用快捷键
Ubuntu操作基本快捷键 * 打开主菜单 = Alt + F1 * 运行 = Alt + F2 * 显示桌面 = Ctrl + Alt + d * 最小化当前窗口 = Alt + F9 * 最大化当 ...
- 一箭双雕打开Genesis
打开记事本,将如下内容填入,保存时将后缀名改为bat @ ECHO 正在清理垃圾文件...del C:\tmp\*.* /f /q@ ECHO 清理完毕@ ECHO OFF@ ECHO.@ ECHO. ...
- MySQL常用简单小命令
1. 登录数据库: mysql -h localhost -u root -p
- Java Hour 59 JVM Heap
程序没有方法区释放一段Heap 上的内存,只有JVM 本身可以去回收内存,这个工作单位就是GC. Garbage Collection GC 用来清理对象,同时也用来移动对象减少内存碎片. JVM 指 ...
- blend 从无到有系列之添加自定义Rectangle样式指定到资源文件
相关链接 http://www.cnblogs.com/wildfeng/archive/2012/03/30/2425248.html http://www.cnblogs.com/jv9/arch ...
- hdu 4091 线性规划
分析转自:http://blog.csdn.net/dongdongzhang_/article/details/7955136 题意 : 背包能装体积为N, 有两种宝石, 数量无限, 不能切割. ...
- google svn 服务器使用(免费SVN服务器)
转自:http://hi.baidu.com/%C0%AF%B1%CA%B9%A4%D7%F7%CA%D2/blog/item/d6f6c6d7707d81d0a044df5f.html 1. 进入h ...
- struts2框架——从后台取得数据集,并在前台页面循环显示
1.CourseBean.java public class CourseBean { private String f_courseId = ""; private String ...