03-1
来源:互联网 发布:网络剧错生哔哩哔哩 编辑:程序博客网 时间:2024/06/13 10:37
/*
title:
问题分类:
#include<math.h>
double a1,a2,a3,a4;
double f(double x){
return a1*pow(x,3)+a2*pow(x,2)+a3*x+a4;
}
int main(){
freopen("in.txt","r",stdin);
while(scanf("%lf %lf %lf %lf",&a1,&a2,&a3,&a4)!=EOF){
double low,high;
scanf("%lf %lf",&low,&high);
if(f(low)==0){
printf("%.2lf\n",low);
continue;
}else if(f(high)==0){
printf("%.2lf\n",high);
continue;
}
while(high-low>1e-3){
if(f(low)*f(high)<0){
double mid=(low+high)/2;
if(f(mid)*f(low)>0){
low=mid;
}else if(f(mid)*f(high)>0){
high=mid;
}
}
}
printf("%.2lf\n",(low+high)/2);
}
return 0;
}
title:
问题分类:
*/
科学计数法1e-3
判断边界
http://www.patest.cn/contests/mooc-ds/03-1
#include<math.h>
double a1,a2,a3,a4;
double f(double x){
return a1*pow(x,3)+a2*pow(x,2)+a3*x+a4;
}
int main(){
freopen("in.txt","r",stdin);
while(scanf("%lf %lf %lf %lf",&a1,&a2,&a3,&a4)!=EOF){
double low,high;
scanf("%lf %lf",&low,&high);
if(f(low)==0){
printf("%.2lf\n",low);
continue;
}else if(f(high)==0){
printf("%.2lf\n",high);
continue;
}
while(high-low>1e-3){
if(f(low)*f(high)<0){
double mid=(low+high)/2;
if(f(mid)*f(low)>0){
low=mid;
}else if(f(mid)*f(high)>0){
high=mid;
}
}
}
printf("%.2lf\n",(low+high)/2);
}
return 0;
}
0 0
- 03-1
- 2012-03-09-1
- 2012-03-20-1
- 2012-03-23-1
- 2012-03-28-1
- 2012-03-29-1
- Android---03---基础1
- Chapter 1-03
- 03月 1st, 2007
- 03-VTK基础概念(1)
- 03-1三天打鱼两天晒网(15)
- 2015-03-04-pandas(1)
- 2017.03.03 windows编程1
- 03-VTK基础概念(1)
- 分蛋糕 2017-03-1
- 03-1 javaScript的对象(1)
- 2011-8-1 21:05:03
- 第05章 数组 03 练习1
- mysql 查询语句
- C语言程序的存储区域--内存布局
- 并行细化算法
- java调用webservice接口方法
- UVa 232 字符串处理、
- 03-1
- springmvc如何访问静态资源
- 圆圈loader的动画
- dos dir命令简介
- spring已经不再为hibernate4提供daoSupport,.hibernate4.SessionHolder cannot be cast to org.springfra
- C# 中多线程异常的处理
- 设备I/O之“设备的打开和关闭”
- HDFS 上传文件不均衡和Balancer太慢的问题
- 配置sublime文本编缉器,相当好用,相当好看~~