Function Curve

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

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-10-9 12:04:07
File Name :E:\2013ACM\专题学习\数学\积分\HDU4498.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; vector<double>x; void add(int a1,int b1,int c1)//计算a1*x^2 + b1*x + c = 0的解
{
if(a1 == && b1 == )
{
return;
}
if(a1 == )
{
double t = -c1*1.0/b1;
if(t >= && t <= )
x.push_back(t);
return;
}
long long deta = b1*b1 - 4LL*a1*c1;
if(deta < )return;
if(deta == )
{
double t = (-1.0 * b1)/(2.0 * a1);
if(t >= && t <= )
x.push_back(t);
}
else
{
double t1 = (-1.0 * b1 + sqrt(1.0*deta))/(2.0*a1);
double t2 = (-1.0 * b1 - sqrt(1.0*deta))/(2.0*a1);
if(t1 >= && t1 <= )
x.push_back(t1);
if(t2 >= && t2 <= )
x.push_back(t2);
}
}
int A[],B[],C[];
int best;
double F(double x1)
{
return sqrt(1.0 + (x1**A[best] + 1.0 * B[best])*(x1**A[best] + 1.0 * B[best]));
}
double simpson(double a,double b)
{
double c = a + (b-a)/;
return (F(a) + *F(c) + F(b))*(b-a)/;
}
double asr(double a,double b,double eps,double A)
{
double c = a + (b-a)/;
double L = simpson(a,c);
double R = simpson(c,b);
if(fabs(L+R-A) <= *eps)return L+R+(L+R-A)/;
return asr(a,c,eps/,L) + asr(c,b,eps/,R);
}
double asr(double a,double b,double eps)
{
return asr(a,b,eps,simpson(a,b));
} int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int T;
int k,a,b;
scanf("%d",&T);
while(T--)
{
int n;
scanf("%d",&n);
A[] = ;
B[] = ;
C[] = ;
for(int i = ;i <= n;i++)
{
scanf("%d%d%d",&k,&a,&b);
A[i] = k;
B[i] = -*a*k;
C[i] = k*a*a + b;
}
x.clear();
for(int i = ;i <= n;i++)
for(int j = i+;j <= n;j++)
add(A[i]-A[j],B[i] - B[j],C[i] - C[j]);
double ans = ;
x.push_back();
x.push_back();
sort(x.begin(),x.end());
int sz = x.size();
for(int i = ;i < sz-;i++)
{
double x1 = x[i];
double x2 = x[i+];
if(fabs(x2-x1) < 1e-)continue;
double mid = (x1 + x2)/;
best = ;
for(int j = ;j <= n;j++)
{
double tmp1 = mid*mid*A[best] + mid*B[best] + C[best];
double tmp2 = mid*mid*A[j] + mid*B[j] + C[j];
if(tmp2 < tmp1)best = j;
}
ans += asr(x1,x2,1e-);
}
printf("%.2lf\n",ans);
}
return ;
}

HDU 4498 Function Curve (自适应simpson)的更多相关文章

  1. HDU 4498 Function Curve (分段,算曲线积分)

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

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

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

  3. HDU 1724 Ellipse 【自适应Simpson积分】

    Ellipse Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  4. 【BZOJ-1502】月下柠檬树 计算几何 + 自适应Simpson积分

    1502: [NOI2005]月下柠檬树 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1017  Solved: 562[Submit][Status] ...

  5. 自适应Simpson积分

    自适应Simpson积分 作用 如标题所示,这玩意就是当你不会微积分的时候来求积分的. 总所周知,积分的定义就是函数的某一段与坐标轴之间的面积. 那么,自适应Simpson积分就是一种可以再某些精度下 ...

  6. HDU 5608 function [杜教筛]

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

  7. 自适应Simpson法与积分初步

    前言 不知道为什么,今天感觉想要写一下数学的东西,然后就看了一下我还有这个模板不会,顺手写了一下. 没有学过微积分的最好还是看一下求导为好. 求导 听说很多人都不会求导,我写一下吧qwq 令\(f(x ...

  8. HDU 5608 - function

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

  9. 【bzoj1502】[NOI2005]月下柠檬树 自适应Simpson积分

    题目描述 李哲非常非常喜欢柠檬树,特别是在静静的夜晚,当天空中有一弯明月温柔地照亮地面上的景物时,他必会悠闲地坐在他亲手植下的那棵柠檬树旁,独自思索着人生的哲理.李哲是一个喜爱思考的孩子,当他看到在月 ...

随机推荐

  1. Shell命令行中特殊字符与其转义详解(去除特殊含义)

    特殊符号及其转义 大家都知道在一个shell命令是由命令名和它的参数组成的, 比如 cat testfile, 其中cat是命令名, testfile是参数. shell将参数testfile传递给c ...

  2. hadoop控制map个数(转)

    原文链接:https://blog.csdn.net/lylcore/article/details/9136555     hadooop提供了一个设置map个数的参数mapred.map.task ...

  3. javascript设计模式----桥接模式、组合模式、装饰者模式、享元模式

    http://blog.csdn.net/painsonline/article/details/7215087    桥接模式:http://www.cnblogs.com/TomXu/archiv ...

  4. window10 显示QQ图标

  5. .NetCore 利用Jenkins在 Windows平台下打包发布Angular项目

    准备环境 安装Jenkins 首先装node,版本根据实际环境而定(node安装包中包含了npm) 安装一般都配置好了环境变量,检查下如果没有就配置下 Jenkins中安装NPM插件 GIt获取代码 ...

  6. Net WebAPI2

    SwaggerUI ASP.Net WebAPI2   目前在用ASP.NET的 WebAPI2来做后台接口开发,在与前台做测试的时候,总是需要发送一个demo给他,但是这样很麻烦的,他还有可能记不住 ...

  7. elasticsearch query dsl

    1.match / match_phrase / match_phrase_prefix / multi_match[查询] 1.1 match 它会根据所给的字符串,进行分词,然后去找出,包含这些分 ...

  8. CSUOJ Water Drinking

    Description The Happy Desert is full of sands. There is only a kind of animal called camel living on ...

  9. .NET工作准备--01前言

    01应聘须知(已过时) -1.了解软件开发大环境.-2.准备简历:不宜超过一页,永远准备中文,模板. -3.渠道:3大网站,中华英才,前程无忧(51job最给力),智联招聘.现在还有猎聘网和100程序 ...

  10. [转]状态压缩dp(状压dp)

    状态压缩动态规划(简称状压dp)是另一类非常典型的动态规划,通常使用在NP问题的小规模求解中,虽然是指数级别的复杂度,但速度比搜索快,其思想非常值得借鉴. 为了更好的理解状压dp,首先介绍位运算相关的 ...