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 ...
随机推荐
- selenium只打开一个浏览器窗口
from selenium.webdriver import Remote from selenium.webdriver.chrome import options from selenium.co ...
- php 7.3.3安装问题记录
1.checking for libzip... not foundconfigure: error: Please reinstall the libzip distribution 参考:http ...
- sklearn逻辑回归(Logistic Regression)类库总结
class sklearn.linear_model.LogisticRegression(penalty=’l2’, dual=False, tol=0.0001, C=1.0, fit_inter ...
- 守护进程daemon函数
#include <unistd.h> int daemon(int nochdir,int noclose) 在创建精灵进程的时候,往往需要将精灵进程的工作目录修改为"/&q ...
- POJ 3026 Borg Maze(Prim+bfs求各点间距离)
题目链接:http://poj.org/problem?id=3026 题目大意:在一个y行 x列的迷宫中,有可行走的通路空格’ ‘,不可行走的墙’#’,还有两种英文字母A和S,现在从S出发,要求用 ...
- python抓取链家房源信息(二)
试着用scrapy将之前写的抓取链家网信息的重新写了写 然后先是用了第一页的网页作为测试,调试代码,然后发现总是抓取的时候遇见了 类似于这样的问题,并且抓取不到信息 2017-03-28 17:52: ...
- email的传输协议与格式(资源链接)
以下链接为转载. 传输协议: 发:SMTP 收:POP3, IMAP 格式: MIME
- Python使用opencv
Python配置opencv 原理 Python调用opencv的原理是:opencv编译出共享库文件,python把这个共享库文件作为一个模块加载并使用. 通俗点就是,编译opencv的时候开启py ...
- 关于WordPress登录后跳转到指定页面
前面在写模版的时候,有朋友要求网站登录后要跳转的到指定的页面.这个从前还真没遇到过.于是就用万能的搜索(很少百度)找了下,方法基本上就是一个,代码如下: <?php // Fields f ...
- PHP完整的AES加解密算法使用及例子(256位)
依赖PHP自身的mcrypt扩展 <?php class aes { // CRYPTO_CIPHER_BLOCK_SIZE 32 private $_secret_key = 'default ...