hdu 3714 Error Curves(三分)
http://acm.hdu.edu.cn/showproblem.php?pid=3714
【题意】:
题目意思看了很久很久,简单地说就是给你n个二次函数,定义域为[0,1000], 求x在定义域中每个x所在的n个函数的最大值的最小值。很拗口吧,显然这题不是组队或者耐心的做是不知道性质的,至少我没看出来。网上说是三分,我画了几个图,确实是。根据二次函数的性质,增长的快慢已经确定了,那的确是单峰的。那就OK了。另外eps的问题1e-8还是wa,1e-9AC。想了下,因为有系数a,b,c的缘故,一乘就WA了。代码就是三分了,没什么特殊的。(三分,什么时候我能主动的看出你???)
【题解】:
第二个三分,三分啊三分,很难自己看出来啊!!!
【code】:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h> using namespace std; #define eps 1e-9
#define INF 1e15 struct Nod
{
double a,b,c;
}node[]; int n; double func(double a,double b,double c,double x)
{
return a*x*x+b*x+c;
} double getMins(double x)
{
int i;
double maks = -INF;
for(i=;i<n;i++)
{
double temp = func(node[i].a,node[i].b,node[i].c,x);
if(maks<temp)
{
maks = temp;
}
}
return maks;
} void sanfen()
{
double l=,r=,mid,ans = INF;
while(l<=r)
{
mid = (l+r)/;
double temp1 = getMins(mid);
double temp2 = getMins(mid-eps);
if(temp1<temp2)
{
l = mid + eps;
}
else
{
r = mid - eps;
}
if(ans>temp1)
{
ans=temp1;
}
}
printf("%.4lf\n",ans);
} int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
int i;
for(i=;i<n;i++)
{
scanf("%lf%lf%lf",&node[i].a,&node[i].b,&node[i].c);
}
sanfen();
}
return ;
}
hdu 3714 Error Curves(三分)的更多相关文章
- nyoj 1029/hdu 3714 Error Curves 三分
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3714 懂了三分思想和F(x)函数的单调性质,这题也就是水题了 #include "stdio ...
- LA 5009 (HDU 3714) Error Curves (三分)
Error Curves Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu SubmitStatusPr ...
- hdu 3714 Error Curves(三分)
Error Curves Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Tot ...
- HDU 3714 Error Curves
Error Curves 思路:这个题的思路和上一个题的思路一样,但是这个题目卡精度,要在计算时,卡到1e-9. #include<cstdio> #include<cstring& ...
- 三分 HDOJ 3714 Error Curves
题目传送门 /* 三分:凹(凸)函数求极值 */ #include <cstdio> #include <algorithm> #include <cstring> ...
- UVA - 1476 Error Curves 三分
Error Curves Josephina is a clever girl and addicted to Machi ...
- UVALive 5009 Error Curves 三分
//#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include& ...
- Error Curves HDU - 3714
Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a m ...
- HDU 3714/UVA1476 Error Curves
Error Curves Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
随机推荐
- SQL Server批量更新数据
项目中有一个位置需要批量插入几万条数据,批量insert等待时间简直...用SqlBulkCopy后,之前需要1分钟左右的sql现在只要一眨眼(真的只要一眨眼) 稍后这个功能要加到另外一个项目中,另外 ...
- MyBatis(3.2.3) - Integration with Spring
MyBatis-Spring is a submodule of the MyBatis framework, which provides seamless integration with the ...
- Xcode Product -> Archive disabled
You've changed your scheme destination to a simulator instead of "iOS Device". That's why ...
- C++ Iterator迭代器介绍及Iterator迭代器用法代码举例
C++ Iterator迭代器介绍 迭代器可被用来访问一个容器类的所包函的全部元素,其行为像一个指针.举一个例子,你可用一个迭代器来实现对vector容器中所含元素的遍历.有这么几种迭代器如下: 迭代 ...
- win7下将主分区转换成逻辑分区
在了解怎么转换之前,先搞清楚主分区,扩展分区,逻辑分区的基本概念. 主分区,也称为主磁盘分区,和扩展分区.逻辑分区一样,是一种分区类型.主分区中不能再划分其他类型的分区,因此每个主分区都相当于一个逻辑 ...
- 第二十八篇、自定义的UITableViewCell上有图片需要显示,要求网络网络状态为WiFi时,显示图片高清图;网络状态为蜂窝移动网络时,显示图片缩略图
1)SDWebImage会自动帮助开发者缓存图片(包括内存缓存,沙盒缓存),所以我们需要设置用户在WiFi环境下下载的高清图,下次在蜂窝网络状态下打开应用也应显示高清图,而不是去下载缩略图. 2)许多 ...
- Cocos开发中性能优化工具介绍之Visual Studio内存泄漏检测工具——Visual Leak Detector
那么在Windows下有什么好的内存泄漏检测工具呢?微软提供Visual Studio开发工具本身没有什么太好的内存泄漏检测功能,我们可以使用第三方工具Visual Leak Detector(以下简 ...
- spring aop配置及用例说明(4)
欢迎交流转载:http://www.cnblogs.com/shizhongtao/p/3476161.html 这里简单对xml的配置方式做一下描述.代码还是上一篇(http://www.cnblo ...
- 输入与enter
#include<iostream> using namespace std; int main() { char a,b,c; while(scanf("%c%c%c" ...
- 随机森林之Bagging法
摘要:在随机森林介绍中提到了Bagging方法,这里就具体的学习下bagging方法. Bagging方法是一个统计重采样的技术,它的基础是Bootstrap.基本思想是:利用Bootstrap方法重 ...