当前位置:网站首页>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;
}
边栏推荐
- Processsing 鼠标交互 学习
- Beifu PLC passes MC_ Readparameter read configuration parameters of NC axis
- 倍福TwinCAT3实现CSV、TXT文件读写操作
- zoopeeper设置acl权限控制(只允许特定ip访问,加强安全)
- ES6模块
- Deep parsing MySQL binlog
- Summary of some application research cases of UAV Remote Sensing in forest monitoring
- [esp32-c3][rt-thread] run RT-Thread BSP minimum system based on esp32c3
- QT .pri 的建立与使用
- Solution of Splunk iowait alarm
猜你喜欢

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

Learning Processing Zoog

Redis learning - 02 common data types, operation commands and expiration time

Deeply analyze the differences between dangbei box B3, Tencent Aurora 5S and Xiaomi box 4S

黑马笔记---常用API

BigInt:处理大数字(任意长度的整数)

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

opencv高速下载

Openlayers drawing dynamic migration lines and curves

Electron official docs series: Get Started
随机推荐
文件远程同步、备份神器rsync
自定义封装下拉组件
openlayers 绘制动态迁徙线、曲线
LeetCode_栈_中等_150. 逆波兰表达式求值
Software testing - Fundamentals
processing 随机生成线动画
goto语句实现关机小程序
5+API,清除应用缓存
Solution of Splunk iowait alarm
Deep parsing MySQL binlog
How does easygbs solve the abnormal use of intercom function?
程序员必备,一款让你提高工作效率N倍的神器uTools
Redis learning - 02 common data types, operation commands and expiration time
Summary of some application research cases of UAV Remote Sensing in forest monitoring
Source code learning: atomicinteger class code internal logic
Redis learning - 03 transaction
Redis learning - 06 drifting bottle case
倍福PLC选型--如何看电机是多圈绝对值还是单圈绝对值编码器
计组实践实验9——使用CMStudio设计基于分段模型机微程序指令(2)
一个快速切换一个底层实现的思路分享