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. es6笔记(5)Map数据结构

    概要 字典是用来存储不重复key的Hash结构.不同于集合(Set)的一点,字典使用的是[key,value]的形式来存储数据. JavaScript的对象(Object:{})只能用字符串当做key ...

  2. tf.range()函数

    range()函数用于创建数字序列变量,有以下两种形式: range(limit, delta=1, dtype=None, name='range') range(start, limit, del ...

  3. mysql 1045 access denied for user 解决方法

    提示:1045 access denied for user 'root'@'localhost' using password yes方法一: # /etc/init.d/mysql stop #  ...

  4. 【译】SQLskills SQL101:Trace Flags、ERRORLOG、Update Statistics

    最近阅读SQLskills SQL101,将Erin Stellato部分稍作整理.仅提取自己感兴趣的知识点,详细内容请阅读原文. 一.Trace Flags推荐开启三个跟踪标记1118.3023.3 ...

  5. 数链剖分(树的统计Count )

    题目链接:https://cn.vjudge.net/contest/279350#problem/C 具体思路:单点更新,区间查询,查询的时候有两种操作,查询区间最大值和区间和. 注意点:在查询的时 ...

  6. hibernate介绍及环境搭建

    1.前言 hibernate与mybatis的位置一样,都是属于DAO层的框架,代替我们原来的JDBC操作数据库,属于ORM(object relationg mapping. 对象关系映射)框架.O ...

  7. ARMCC和GCC编译ARM代码的软浮点和硬浮点问题【转】

    转自:https://blog.csdn.net/hunanchenxingyu/article/details/47003279 本文介绍了ARM代码编译时的软浮点(soft-float)和硬浮点( ...

  8. 解读Android LOG机制的实现【转】

    转自:http://www.cnblogs.com/hoys/archive/2011/09/30/2196199.html http://armboard.taobao.com/ Android提供 ...

  9. Linux 抽象网络设备简介

    Linux 抽象网络设备简介 和磁盘设备类似,Linux 用户想要使用网络功能,不能通过直接操作硬件完成,而需要直接或间接的操作一个 Linux 为我们抽象出来的设备,既通用的 Linux 网络设备来 ...

  10. centos6.8安装mysql5.6【转】

    首先先要去看看本机有没有默认的mysql, 本地默认有的,我们应先卸载,在安装新的这个逻辑. rpm -qa | grep mysql 我本机默认安装的mysql5.1.73 下一步删除 rpm -e ...