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

    Problem SPOJ Solution 考虑任意一个作为矩阵四个角的位置 \(r_i \oplus c_j\oplus a_{i,j}\oplus x_{i,j}=0\) \(r_i \oplus ...

  2. 62.Unique Paths---dp

    题目链接 题目大意:给一个m*n的方格,从左上角走到右下角,中间无任何障碍,问有多少种走法. 法一:DFS,超时,简单模板深搜,无任何剪枝,结果一半的数据超时.代码如下: public int uni ...

  3. angular项目中使用ngSemantic

    npm install ng-semantic --save npm install jquery --save 下载 Official Semantic UI bundle ( .zip ) fro ...

  4. 用js实现登录的简单验证

    实现过程示意图 代码 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> &l ...

  5. 设计模式--工厂模式 caffe_layer注册

    来源:http://www.cnblogs.com/zhouqiang/archive/2012/07/20/2601365.html 来源:http://blog.luoyetx.com/2016/ ...

  6. ntp 控制报文

    //make the procedure into block//2014.7.23 OK//#include "CSocket.h" #define NTP_SERVER_IP ...

  7. go的匿名组合

    golang也提供了继承机制,但采用组合的文法,因此称为匿名组合.与其他语言不同, golang很清晰地展示出类的内存布局是怎样的. 一  非指针方式的组合 1)基本语法 type base stru ...

  8. 自家人不认识自家人——考你一道有趣的Javascript小题目

    今天的内容很简单,给大家分享一个有趣的Javascript小题目. 题目很简单,就是填空: var a = ______; var b = a; alert(a==b); // alert " ...

  9. python中list的底层实现

    这里不讨论具体的实现细节,主要是转载这篇文章: 顺序表的原理与python中的list类型. 原文就不贴过来了,总结一下: 确定数据类型的意义在于确定一个数据在内存中占据的空间大小以及如何解释一段内存 ...

  10. 在ubuntu下安装kaldi基本步骤

    注:最近在学习kaldi语音识别工具,在安装过程中遇到了许多问题,在此记录,以备后需. 在一开始,我看了这篇博客(http://blog.topspeedsnail.com/archives/1001 ...