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 ...
随机推荐
- 6.Python3标准库--数学运算
''' 作为一种通用的变成语言,Python经常用来解决数学问题.它包含一些用于管理整数和浮点数的内置类型,这很适合完成一般应用中可能出现的基本数学运算. 而标准库中包含一些用于满足更高级需求的模块. ...
- laravel 上传文件到亚马逊 aws s3
参考: https://github.com/aws/aws-sdk-php-laravel https://www.jianshu.com/p/e48d82bff20b
- [ python ] 网络编程(1)
在本地电脑上有两个python文件 regist.py .login.py 一个注册,一个登录.这两个python一个是写用户信息,一个是读用户信息,要怎么做呢? 通过之前的知识,我们可以通过 reg ...
- centos6.5 使用 rpm 安装 mysql
从mysql网站下载mysql rpm安装包(包括server.client) 1.安装server rpm -ivh MySQL-server-5.6.19-1.el6.x86_64.rpm 强制安 ...
- 转:google测试分享-问题和挑战
原文: http://blog.sina.com.cn/s/blog_6cf812be0102vxer.html 前言:这个系列分享的内容大部分都是出自于<google是如何测试的>的书, ...
- 根据名字杀死进程Killall
Killall命令可以用来给一个特定的进程发送一个信号.这个信号默认情况下是SIGTERM,但也可以由killall命令使用参数来指定其它信号.现在让我们通过一些实际的例子来看看这个命令的实际用法. ...
- span文字里面自动换行时怎么办
可以用white-space:nowrap来强制文字不换行,知道遇到<br>为止
- Valid Parentheses——栈经典
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the inpu ...
- Jmeter----连接mysql数据库及常见问题处理
jmeter要链接mysql数据库,首先得下载mysql jdbc驱动包,(注:驱动包的版本一定要与你数据库的版本匹配,驱动版本低于mysql版本有可能会导致连接失败报错) 本人的数据为5.7.18, ...
- ORA-**,oracle 12c操作问题
https://blog.csdn.net/typa01_kk/article/details/41924321