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 ...
随机推荐
- 使用air16sdk打包ipa报错
报错如下图: google下 https://forums.adobe.com/thread/1659726 说明了一切 首先:air sdk中打包ipa 需要使用ios sdk的路径但是这个路径最后 ...
- ADF_Controller系列5_通过绑定TasksFlow创建Train
2015-02-14 Created By BaoXinjian
- 查询数组里有多少个数在[L,R]范围中(二分)
使用两次二分即可得到这个值 比如现在有一个vector<int> vec,里面存放的是有序数列. 我们现在希望找出范围在[L,R]之间的数有多少个. 则有cnt = upper_bound ...
- 多个字段用and和or时要注意用括号。
多个字段用and和or时要注意用括号. 新技能get! create table wly_test (name1 varchar2(10),number1 number(6),score1 numbe ...
- 剑指Offer:面试题28——字符串的排列(java实现)(待序)
问题描述: 输入一个字符串,按字典序打印出该字符串中字符的所有排列.例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba. 结果请按字母 ...
- .bashrc文件是干什么的(转)
使用man bash命令查看到的联机帮助文件中的相关解释如下:.bashrc - The individual per-interactive-shell startup file. 这个文件主要保存 ...
- Marathon
早上,挣扎到十点才起,刚好去吃过饭,来教研室,等待着中午的马拉松. 中午一直是很激动,有些紧张.一直到整个马拉松跑完,我达到了我唯一的目标,保持均匀的呼吸节奏.但我能明显感觉到,我并没有拼尽全力.我不 ...
- U盘分区之后如何恢复
操作步骤: 1.插入U盘. 2.按windows键,右键点击“运行”,再左键点击以管理员身份运行. 3.输入diskpart,按enter. 4.输入list disk,按enter. 5.之后会看到 ...
- gps转百度地图
HttpResponse res=WS.url(mapUrl+"/ag/coord/convert?from=0&to=4&x="+longitude+" ...
- boost的线程池和内存池 智能指针
内存池为boost自带的 #include <boost/pool/pool.hpp> 或者另外一个开源的库: nedmalloc 一个高效率的库 线程池需要下载另外一个开源库 http: ...