1. //#pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<cstdlib>
  5. #include<algorithm>
  6. #include<iostream>
  7. #include<sstream>
  8. #include<cmath>
  9. #include<climits>
  10. #include<string>
  11. #include<map>
  12. #include<queue>
  13. #include<vector>
  14. #include<stack>
  15. #include<set>
  16. using namespace std;
  17. typedef long long ll;
  18. typedef unsigned long long ull;
  19. typedef pair<int,int> pii;
  20. #define pb(a) push(a)
  21. #define INF 0x1f1f1f1f
  22. #define lson idx<<1,l,mid
  23. #define rson idx<<1|1,mid+1,r
  24. #define PI 3.1415926535898
  25. template<class T> T min(const T& a,const T& b,const T& c) {
  26. return min(min(a,b),min(a,c));
  27. }
  28. template<class T> T max(const T& a,const T& b,const T& c) {
  29. return max(max(a,b),max(a,c));
  30. }
  31. void debug() {
  32. #ifdef ONLINE_JUDGE
  33. #else
  34.  
  35. freopen("in.txt","r",stdin);
  36. //freopen("d:\\out1.txt","w",stdout);
  37. #endif
  38. }
  39. int getch() {
  40. int ch;
  41. while((ch=getchar())!=EOF) {
  42. if(ch!=' '&&ch!='\n')return ch;
  43. }
  44. return EOF;
  45. }
  46.  
  47. const int maxn=;
  48. int a[maxn],b[maxn],c[maxn];
  49. double f(int i,double x)
  50. {
  51. return a[i]*x*x+b[i]*x+c[i];
  52. }
  53. int n;
  54. double check(double x)
  55. {
  56. double maxx=f(,x);
  57. for(int i=;i<=n;i++)
  58. maxx=max(maxx,f(i,x));
  59. return maxx;
  60. }
  61. int main()
  62. {
  63. int t;
  64. scanf("%d",&t);
  65. for(int ca=;ca<=t;ca++)
  66. {
  67. //int n;
  68. scanf("%d",&n);
  69. double maxx=-(<<);
  70. for(int i=;i<=n;i++)
  71. {
  72. scanf("%d%d%d",&a[i],&b[i],&c[i]);
  73. }
  74. double l=,r=;
  75. const double eps=1e-;
  76. while(r-l>eps)
  77. {
  78. double ll=(*l+r)/;
  79. double rr=(l+*r)/;
  80. if(check(ll)<check(rr))
  81. r=rr;
  82. else l=ll;
  83. }
  84. printf("%.4lf\n",check(l));
  85. }
  86. return ;
  87. }

UVALive 5009 Error Curves 三分的更多相关文章

  1. UVA 5009 Error Curves

    Problem Description Josephina is a clever girl and addicted to Machine Learning recently. She pays m ...

  2. UVA - 1476 Error Curves 三分

                                           Error Curves Josephina is a clever girl and addicted to Machi ...

  3. nyoj 1029/hdu 3714 Error Curves 三分

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3714 懂了三分思想和F(x)函数的单调性质,这题也就是水题了 #include "stdio ...

  4. hdu 3714 Error Curves(三分)

    http://acm.hdu.edu.cn/showproblem.php?pid=3714 [题意]: 题目意思看了很久很久,简单地说就是给你n个二次函数,定义域为[0,1000], 求x在定义域中 ...

  5. LA 5009 (HDU 3714) Error Curves (三分)

    Error Curves Time Limit:3000MS    Memory Limit:0KB    64bit IO Format:%lld & %llu SubmitStatusPr ...

  6. 【单峰函数,三分搜索算法(Ternary_Search)】UVa 1476 - Error Curves

    Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a m ...

  7. hdu 3714 Error Curves(三分)

    Error Curves Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Tot ...

  8. 三分 HDOJ 3714 Error Curves

    题目传送门 /* 三分:凹(凸)函数求极值 */ #include <cstdio> #include <algorithm> #include <cstring> ...

  9. Error Curves(2010成都现场赛题)

    F - Error Curves Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Descript ...

随机推荐

  1. 使用air16sdk打包ipa报错

    报错如下图: google下 https://forums.adobe.com/thread/1659726 说明了一切 首先:air sdk中打包ipa 需要使用ios sdk的路径但是这个路径最后 ...

  2. ADF_Controller系列5_通过绑定TasksFlow创建Train

    2015-02-14 Created By BaoXinjian

  3. 查询数组里有多少个数在[L,R]范围中(二分)

    使用两次二分即可得到这个值 比如现在有一个vector<int> vec,里面存放的是有序数列. 我们现在希望找出范围在[L,R]之间的数有多少个. 则有cnt = upper_bound ...

  4. 多个字段用and和or时要注意用括号。

    多个字段用and和or时要注意用括号. 新技能get! create table wly_test (name1 varchar2(10),number1 number(6),score1 numbe ...

  5. 剑指Offer:面试题28——字符串的排列(java实现)(待序)

    问题描述: 输入一个字符串,按字典序打印出该字符串中字符的所有排列.例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba. 结果请按字母 ...

  6. .bashrc文件是干什么的(转)

    使用man bash命令查看到的联机帮助文件中的相关解释如下:.bashrc - The individual per-interactive-shell startup file. 这个文件主要保存 ...

  7. Marathon

    早上,挣扎到十点才起,刚好去吃过饭,来教研室,等待着中午的马拉松. 中午一直是很激动,有些紧张.一直到整个马拉松跑完,我达到了我唯一的目标,保持均匀的呼吸节奏.但我能明显感觉到,我并没有拼尽全力.我不 ...

  8. U盘分区之后如何恢复

    操作步骤: 1.插入U盘. 2.按windows键,右键点击“运行”,再左键点击以管理员身份运行. 3.输入diskpart,按enter. 4.输入list disk,按enter. 5.之后会看到 ...

  9. gps转百度地图

    HttpResponse res=WS.url(mapUrl+"/ag/coord/convert?from=0&to=4&x="+longitude+" ...

  10. boost的线程池和内存池 智能指针

    内存池为boost自带的 #include <boost/pool/pool.hpp> 或者另外一个开源的库: nedmalloc 一个高效率的库 线程池需要下载另外一个开源库 http: ...