UVALive 5009 Error Curves 三分
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<sstream>
#include<cmath>
#include<climits>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb(a) push(a)
#define INF 0x1f1f1f1f
#define lson idx<<1,l,mid
#define rson idx<<1|1,mid+1,r
#define PI 3.1415926535898
template<class T> T min(const T& a,const T& b,const T& c) {
return min(min(a,b),min(a,c));
}
template<class T> T max(const T& a,const T& b,const T& c) {
return max(max(a,b),max(a,c));
}
void debug() {
#ifdef ONLINE_JUDGE
#else freopen("in.txt","r",stdin);
//freopen("d:\\out1.txt","w",stdout);
#endif
}
int getch() {
int ch;
while((ch=getchar())!=EOF) {
if(ch!=' '&&ch!='\n')return ch;
}
return EOF;
} const int maxn=;
int a[maxn],b[maxn],c[maxn];
double f(int i,double x)
{
return a[i]*x*x+b[i]*x+c[i];
}
int n;
double check(double x)
{
double maxx=f(,x);
for(int i=;i<=n;i++)
maxx=max(maxx,f(i,x));
return maxx;
}
int main()
{
int t;
scanf("%d",&t);
for(int ca=;ca<=t;ca++)
{
//int n;
scanf("%d",&n);
double maxx=-(<<);
for(int i=;i<=n;i++)
{
scanf("%d%d%d",&a[i],&b[i],&c[i]);
}
double l=,r=;
const double eps=1e-;
while(r-l>eps)
{
double ll=(*l+r)/;
double rr=(l+*r)/;
if(check(ll)<check(rr))
r=rr;
else l=ll;
}
printf("%.4lf\n",check(l));
}
return ;
}
UVALive 5009 Error Curves 三分的更多相关文章
- UVA 5009 Error Curves
Problem Description Josephina is a clever girl and addicted to Machine Learning recently. She pays m ...
- UVA - 1476 Error Curves 三分
Error Curves Josephina is a clever girl and addicted to Machi ...
- nyoj 1029/hdu 3714 Error Curves 三分
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3714 懂了三分思想和F(x)函数的单调性质,这题也就是水题了 #include "stdio ...
- hdu 3714 Error Curves(三分)
http://acm.hdu.edu.cn/showproblem.php?pid=3714 [题意]: 题目意思看了很久很久,简单地说就是给你n个二次函数,定义域为[0,1000], 求x在定义域中 ...
- LA 5009 (HDU 3714) Error Curves (三分)
Error Curves Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu SubmitStatusPr ...
- 【单峰函数,三分搜索算法(Ternary_Search)】UVa 1476 - Error Curves
Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a m ...
- hdu 3714 Error Curves(三分)
Error Curves Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tot ...
- 三分 HDOJ 3714 Error Curves
题目传送门 /* 三分:凹(凸)函数求极值 */ #include <cstdio> #include <algorithm> #include <cstring> ...
- Error Curves(2010成都现场赛题)
F - Error Curves Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Descript ...
随机推荐
- 主从Reactor多线程模型
Reactor 单线程--多线程--主从多线程
- PLSQL 逻辑多线程
PROCEDURE get_sheetid(i_topic IN VARCHAR2, o_newsheetid OUT VARCHAR2) IS PRAGMA AUTONOMOUS_TRANSA ...
- c语言内存对齐问题
#include <stdio.h>#pragma pack(4)struct stu{char a;short b;int c;char d;};int main(){printf(&q ...
- Bugtags 与其它产品的区别
如果您刚刚接触 Bugtags,可能心里会有这样的疑问,下面将介绍 Bugtags 与其它的一些产品的区别. Bugtags 不是做统计的 SDK 大家都会在 App 里集成用户数据统计的 SDK,但 ...
- NDK SO 库开发与使用中的 ABI 构架选择
Bugtags V1.2.7 引入了 NDK SO 库,在集成的时候,遇到不同的 SO 库打包到 APK 时,安装在某些机器上,出现 java.lang.UnsatisfiedLinkError 加载 ...
- Handler基本概念
Handler基本概念: Handler主要用于异步消息的处理:当发出一个消息之后,首先进入一个消息队列,发送消息的函数即刻返回,而另外一个部分逐个的在消息队列中将消息取出,然后对消息进行出来,就是发 ...
- eclipse 代码自动提示
从Window -> preferences -> Java -> Editor -> Content assist -> Auto-Activation下,我们可以在& ...
- 黑马程序员_JAVA基础知识总结3
------- android培训.java培训.期待与您交流! ---------- Java源文件的扩展名是.java,编译之后生成.class的文件.所有的类都有一个共同的继承祖先Object类 ...
- Marathon
早上,挣扎到十点才起,刚好去吃过饭,来教研室,等待着中午的马拉松. 中午一直是很激动,有些紧张.一直到整个马拉松跑完,我达到了我唯一的目标,保持均匀的呼吸节奏.但我能明显感觉到,我并没有拼尽全力.我不 ...
- 2016-07-07: 重新编译时vc90.pdb不是创建此预编译头时使用的pdb文件
使用VS2008在一个解决方案中包含多个项目时,当设置多个项目的中间目录为同一个目录时,在增量编译时出现"重新编译时vc90.pdb不是创建此预编译头时使用的pdb文件,请重新创建预编译头问 ...