day2 HDU - 2899
2016-07-21 14:16
351 查看
#include"iostream" #include"iomanip" #include"math.h" using namespace std; double f(double x) { return 42*x*x*x*x*x*x+48*x*x*x*x*x+ 4000 21*x*x+10*x; } double F(double x,double y) { return 6*x*x*x*x*x*x*x+8*x*x*x*x*x*x+7*x*x*x+5*x*x-y*x; } double find(double y) { double l,r,mid,k; l=0; r=100; while(l+0.00001<r) { mid=(l+r)/2.0; k=f(mid); if(fabs(k-y)>0.00001) { if(k>y)r=mid; else l=mid; } else break; } return mid; } int main() { int t; double y,k; cin>>t; while(t--) { cin>>y; if(f(100)<=y) cout<<fixed<<setprecision(4)<<F(100,y)<<endl; else { cout<<fixed<<setprecision(4)<<F(find(y),y)<<endl; } } return 0; }要求解函数极值点,二分求解导数零点,注意控制精度,以二分值点导数值与目标值差是否超过精度作为判断条件
相关文章推荐
- Android原生应用集成ReactNative坑总结
- RSA加密算法及其与SpringMVC集成
- mongoDB 学习笔记(二)聚合查询
- 连接整数
- 浅析HTTP协议
- Ping命令的设计与实现
- Spring任务调度器之Task的使用
- windows文件复制到linux乱码,转换文件名编码
- JQuery Mobile 知识点与实例演示Android手机APP
- 2014NOIP复赛模拟练习 设置喷水池 解题报告
- Thinkphp3.2.3整合phpqrcode生成带logo的二维码
- vs2013编译源码libcurl生成dll动态库
- mmap直接控制底层【转】
- 开一个线程来处理 耗时的操作
- SecureCRT 回车按键值修改
- 基于CentOS 7系统的两部LAMP服务器,通过NFS共享同一个php网页的实现
- HBase Replication源码解析之HLog读取
- 个人学习-java-结构模式(23种设计模式)
- js获取输入框信息
- nodejs-- npm模块管理器