Function Curve

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 31    Accepted Submission(s): 10

Problem Description
Given sequences of k1, k2, … kn, a1, a2, …, an and b1, b2, …, bn. Consider following function: 

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?
 
Input
The first line of the input contains one integer T (1<=T<=15), representing the number of test cases. 
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 ) .
 
Output
For each test case, output a real number L which is rounded to 2 digits after the decimal point, means the length of the curve.
 
Sample Input
2
3
1 2 3
4 5 6
7 8 9
1
4 5 6
 
Sample Output
215.56
278.91

Hint

All test cases are generated randomly.

 
Source
 
Recommend
liuyiding
 

写起来太多了,希望没有写错了。,基本和代码实现对应的

 /* ***********************************************
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 (分段,算曲线积分)的更多相关文章

  1. HDU 4498 Function Curve (分段, simpson)

    转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 最近太逗了...感觉成都要打铁了...只能给队友端 ...

  2. HDU 4498 Function Curve (自适应simpson)

    Function Curve Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)To ...

  3. 洛谷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> ...

  4. HDU 5608 function [杜教筛]

    HDU 5608 function 题意:数论函数满足\(N^2-3N+2=\sum_{d|N} f(d)\),求前缀和 裸题-连卷上\(1\)都告诉你了 预处理\(S(n)\)的话反演一下用枚举倍数 ...

  5. HDU 5608 - function

    HDU 5608 - function 套路题 图片来自: https://blog.csdn.net/V5ZSQ/article/details/52116285 杜教筛思想,根号递归下去. 先搞出 ...

  6. HDU 6038 - Function | 2017 Multi-University Training Contest 1

    /* HDU 6038 - Function [ 置换,构图 ] 题意: 给出两组排列 a[], b[] 问 满足 f(i) = b[f(a[i])] 的 f 的数目 分析: 假设 a[] = {2, ...

  7. 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 ...

  8. HDU 5875 Function(ST表+二分)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5875 [题目大意] 给出一个数列,同时给出多个询问,每个询问给出一个区间,要求算出区间从左边开始不 ...

  9. 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 ...

随机推荐

  1. 防范SQL注入

    使用占位符的方式写查询语句hibernate

  2. Adding Completion to (interactive)

      Adding Completion to (interactive) Author: Tubo Question: Is there any way to add my own completio ...

  3. Elasticsearch分片&副本分配

    集群索引中可能由多个分片构成,并且每个分片可以拥有多个副本,将一个单独的索引分为多个分片,可以处理不能在单一服务器上运行的 大型索引. 由于每个分片有多个副本,通过副本分配到多个服务器,可以提高查询的 ...

  4. python基本数据类型的用法和区别

    原文:http://www.cnblogs.com/soaringEveryday/p/5044007.html Python语言简洁明了,可以用较少的代码实现同样的功能.这其中Python的四个内置 ...

  5. [实战]MVC5+EF6+MySql企业网盘实战(21)——网盘操作日志

    写在前面 上篇文章介绍了一个bootstrap的分页插件,这篇将弄一个完整的例子,就以日志分页为例说明如何请求服务端然后进行分页. 系列文章 [EF]vs15+ef6+mysql code first ...

  6. Python爬虫笔记(一)

    个人笔记,仅适合个人使用(大部分摘抄自python修行路) 1.爬虫Response的内容 便是所要获取的页面内容,类型可能是HTML,Json(json数据处理链接)字符串,二进制数据(图片或者视频 ...

  7. C++的一道变态题

    题目大概是这样的:有两个数组a[N],b[N],求构造 b[i]=a[0]*a[1]*a[2]*...a[N-1]/a[i], 要求: .不能使用除法. .空间复杂度O(1),时间复杂度O(n). . ...

  8. markdown入门语法

    目录 一: 标题 二:字体 三: 引用 四:分割线 五:图片 六:超链接 七:列表 九: 代码块 一: 标题 # 一级标题 ## 二级标题 ####### 最大六级标题 二:字体 1. 加粗字体 加粗 ...

  9. 【Python】闭包Closure

    原来这就是闭包啊... 还是上次面试,被问只不知掉js里面的闭包 闭包,没听过啊...什么是闭包 回来查了下,原来这货叫闭包啊...... —————————————————————————————— ...

  10. Python开发基础-Day30多线程锁机制

    GIL(全局解释器锁) GIL并不是Python的特性,它是在实现Python解析器(CPython)时所引入的一个概念,是为了实现不同线程对共享资源访问的互斥,才引入了GIL 在Cpython解释器 ...