HDU 4498 Function Curve (分段,算曲线积分)
Function Curve
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 31 Accepted Submission(s): 10

Then we draw F(x) on a xy-plane, the value of x is in the range of [0,100]. Of course, we can get a curve from that plane.
Can you calculate the length of this curve?
Then T blocks follow, which describe different test cases.
The first line of a block contains an integer n ( 1 <= n <= 50 ).
Then followed by n lines, each line contains three integers ki, ai, bi ( 0<=ai, bi<100, 0<ki<100 ) .
3
1 2 3
4 5 6
7 8 9
1
4 5 6
278.91
All test cases are generated randomly.



写起来太多了,希望没有写错了。,基本和代码实现对应的
/* ***********************************************
Author :kuangbin
Created Time :2013/8/24 13:45:56
File Name :F:\2013ACM练习\比赛练习\2013通化邀请赛\1006.cpp
************************************************ */ #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
double k[],a[],b[];
vector<double>p;
const double eps = 1e-;
void add(double a1,double b1,double c1)
{
if(fabs(a1) < eps && fabs(b1) < eps)
return;
if(fabs(a1) < eps)
{
double x = -c1/b1;
if(x >= && x <= )
p.push_back(x);
return;
}
double tmp = b1*b1 - *a1*c1;
if(fabs(tmp) < eps)
{
double x = -b1/(*a1);
if(x >= && x <= )
p.push_back(x);
return;
}
else if(tmp <=-eps)
{
return;
}
double x1 = (-b1+sqrt(tmp))/(*a1);
double x2 = (-b1-sqrt(tmp))/(*a1);
if(x1 >= && x1 <= )
p.push_back(x1);
if(x2 >= && x2 <= )
p.push_back(x2);
}
double calc(double x)
{
return x*sqrt(+x*x)/ + log(x+sqrt(+x*x))/;
}
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int T;
int n;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i = ;i < n;i++)
scanf("%lf%lf%lf",&k[i],&a[i],&b[i]);
p.clear();
for(int i = ;i < n;i++)
add(k[i],-*k[i]*a[i],k[i]*a[i]*a[i]+b[i]-);
for(int i = ;i < n;i++)
for(int j = i+;j < n;j++)
{
add(k[i]-k[j],*k[j]*a[j]-*k[i]*a[i],k[i]*a[i]*a[i]+b[i]-k[j]*a[j]*a[j]-b[j]);
}
p.push_back();
p.push_back();
double ans = ;
sort(p.begin(),p.end());
int sz = p.size();
for(int i = ;i < sz;i++)
{
if(p[i] - p[i-] < eps)continue;
double tmp = (p[i] + p[i-])/;
int tt = ;
for(int j = ;j < n;j++)
if( k[j]*(tmp-a[j])*(tmp-a[j])+b[j] < k[tt]*(tmp-a[tt])*(tmp-a[tt])+b[tt])
tt = j;
if(k[tt]*(tmp-a[tt])*(tmp-a[tt])+b[tt] > )
{
ans += p[i] - p[i-];
continue;
}
ans += (calc(*k[tt]*(p[i]-a[tt]))-calc(*k[tt]*(p[i-]-a[tt])))/(*k[tt]); }
printf("%.2lf\n",ans);
}
return ;
}
HDU 4498 Function Curve (分段,算曲线积分)的更多相关文章
- HDU 4498 Function Curve (分段, simpson)
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove 最近太逗了...感觉成都要打铁了...只能给队友端 ...
- HDU 4498 Function Curve (自适应simpson)
Function Curve Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)To ...
- 洛谷P1464 Function HDU P1579 Function Run Fun
洛谷P1464 Function HDU P1579 Function Run Fun 题目描述 对于一个递归函数w(a,b,c) 如果a≤0 or b≤0 or c≤0就返回值11. 如果a> ...
- HDU 5608 function [杜教筛]
HDU 5608 function 题意:数论函数满足\(N^2-3N+2=\sum_{d|N} f(d)\),求前缀和 裸题-连卷上\(1\)都告诉你了 预处理\(S(n)\)的话反演一下用枚举倍数 ...
- HDU 5608 - function
HDU 5608 - function 套路题 图片来自: https://blog.csdn.net/V5ZSQ/article/details/52116285 杜教筛思想,根号递归下去. 先搞出 ...
- HDU 6038 - Function | 2017 Multi-University Training Contest 1
/* HDU 6038 - Function [ 置换,构图 ] 题意: 给出两组排列 a[], b[] 问 满足 f(i) = b[f(a[i])] 的 f 的数目 分析: 假设 a[] = {2, ...
- HDU 5875 Function 【倍增】 (2016 ACM/ICPC Asia Regional Dalian Online)
Function Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total ...
- HDU 5875 Function(ST表+二分)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5875 [题目大意] 给出一个数列,同时给出多个询问,每个询问给出一个区间,要求算出区间从左边开始不 ...
- 2017 Multi-University Training Contest - Team 1 1006&&HDU 6038 Function【DFS+数论】
Function Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total ...
随机推荐
- c json实战引擎六 , 感觉还行
前言 看到六, 自然有 一二三四五 ... 为什么还要写呢. 可能是它还需要活着 : ) 挣扎升级中 . c json 上面代码也存在于下面项目中(维护的最及时) structc json 这次版本 ...
- caffe Python API 之SoftmaxWithLoss
net.loss = caffe.layers.SoftmaxWithLoss(net.fc3, net.label) 输出: layer { name: "loss" type: ...
- Jmeter组件和属性(二)
Jmeter脚本开发原则 简单.正确.高效.简单:去除无关的组件,同时能复用的尽量复用.正确:对脚本或者业务正确性进行必要的判断,不能少也不能多.(200),业务错误的情况下,也可能返回200,必须用 ...
- mysql的两种存储引擎
MySQL 有多种存储引擎,目前常用的是 MyISAM 和 InnoDB 这两个引擎,除了这两个引擎以为还有许多其他引擎,有官方的,也有一些公司自己研发的.这篇文章主要简单概述一下常用常见的 MySQ ...
- Cookie 与 网络通信
通信协议是什么?(ftp.http.https.file...) 交流的规则 举例: 汉语.英语.法语.德语 (百度百科:通信协议) 通信协议是指双方实体完成通信或服务所必须遵循的规则和约定.通过通信 ...
- 不需要打密码的sudo方法
Linux下频繁输入sudo很麻烦.如果你的账户已经是sudoer了,那么编辑/etc/sudoers,将 %sudo ALL=(ALL:ALL) ALL 修改为: %sudo ALL=(ALL) N ...
- apache Apache winnt_accept: Asynchronous AcceptEx failed 错误的解决
httpd配置文件中添加: AcceptFilter http noneAcceptFilter https none apache优化: http://blog.csdn.net/hytfly/ar ...
- 使用亚马逊云服务器EC2做深度学习(二)配置Jupyter Notebook服务器
这是<使用亚马逊云服务器EC2做深度学习>系列的第二篇文章. (一)申请竞价实例 (二)配置Jupyter Notebook服务器 (三)配置TensorFlow (四)配置好的系统 ...
- plan-6.17周末
喷完了自己,浑身舒爽. 搞个计划,最近要学东西,以提交博客为准,提交了才认为ok. 1.python的新书<<Fluent python>>不错,老的python资料已经满足不 ...
- 【51nod】1594 Gcd and Phi
题解 跟随小迪学姐的步伐,学习一下数论 小迪学姐太巨了! 这道题的式子很好推嘛 \(\sum_{i = 1}^{n} \sum_{j = 1}^{n} \sum_{d|\phi(i),\phi(j)} ...