当前位置:网站首页>UVA10341 solve it 二分
UVA10341 solve it 二分
2022-06-26 12:39:00 【YJEthan】
题意:求f(x)=p*e^-x+q*sin(x)+r*cos(x)+s*tan(x)+t*x*x+u=0,0<=x<=1
思路二分;
#include<stdio.h>
#include<math.h>
typedef double dd;
int p,q,r,s,t,u;
dd solve(dd x)
{
return p*exp(-x)+q*sin(x)+r*cos(x)+s*tan(x)+t*x*x+u;
}
int main()
{
while(scanf("%d%d%d%d%d%d",&p,&q,&r,&s,&t,&u)!=EOF)
{
if(solve(0)<0||solve(1)>0)
{
printf("No solution\n");
continue;
}
dd mid=0.5,l=0.0,r=1.0;
while(fabs(solve(mid))>=0.00000001)//这里也可也写作while(r-l>=0.00000001)
{
if(solve(mid)>0)
l=mid;
else
r=mid;
mid=(l+r)/2.0;
}
printf("%.4lf\n",mid);
}
return 0;
}
边栏推荐
- 软件测试 - 概念篇
- 不到40行代码手撸一个BlocProvider
- 国标GB28181协议EasyGBS视频平台TCP主动模式拉流异常情况修复
- National standard gb28181 protocol easygbs cascaded universal vision platform, how to deal with live message 403?
- [BSidesCF 2019]Kookie 1
- Xiaobai lazy special-win10-win11 one click installation version
- Record a phpcms9.6.3 vulnerability to use the getshell to the intranet domain control
- Beifu PLC passes MC_ Readparameter read configuration parameters of NC axis
- Biff TwinCAT can quickly detect the physical connection and EtherCAT network through emergency scan
- goto语句实现关机小程序
猜你喜欢

Openlayers drawing dynamic migration lines and curves

This function has none of deterministic, no SQL solution

【Spark】.scala文件在IDEA中几种图标的解释

倍福PLC通过程序获取系统时间、本地时间、当前时区以及系统时间时区转换

Power Designer - Custom Comment button

【网络是怎么连接的】第二章(下):一个网络包的接收

Software testing - concept

【网络是怎么连接的】第一章:浏览器生成消息

Tiger DAO VC产品正式上线,Seektiger生态的有力补充

Redis learning - 01 introduction, installation and configuration
随机推荐
软件测试 - 基础篇
Electron official docs series: Processes in Electron
第01章_Linux下MySQL的安装与使用
sql 将数据表b字段值赋值到数据表a中某一列
Is it safe for the head teacher to open a stock account and open an account for financial management?
Electron official docs series: References
KVM 显卡透传 —— 筑梦之路
Redis learning - 04 persistence
Less than 40 lines of code to create a blocprovider
PostGIS calculation angle
Word文档导出(使用固定模板)
无人机遥感在森林监测的部分应用研究案例总结
BigInt:处理大数字(任意长度的整数)
计组实践实验9——使用CMStudio设计基于分段模型机微程序指令(2)
轻流完成与「DaoCloud Enterprise 云原生应用云平台」兼容性认证
Software testing - Fundamentals
Sharing ideas for a quick switch to an underlying implementation
National standard gb28181 protocol easygbs video platform TCP active mode streaming exception repair
processing 函数translate(mouseX, mouseY)学习
详细讲解C语言10(C语言系列)