poj3929
题意:

如上图放置的一个圆锥,告诉你从圆锥顶的洞中流出多少体积的水,求现在水面高度。。
思路:
无聊时做的一道题,实际上就是一道高数题,重积分,可惜我高数本来也不好而且还忘光了,积了很久,而且错了很多遍。。mark一下。。
本来还想偷懒最难积分的最后一重想用自适应的simpson积分公式。。无奈精度要求太高一直都是TLE。。
code:
/*
* Author: Yzcstc
* Created Time: 2014/10/2 13:59:16
* File Name: poj3929.cpp
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<ctime>
#define repf(i, a, b) for (int i = (a); i <= (b); ++i)
#define repd(i, a, b) for (int i = (a); i >= (b); --i)
#define M0(x) memset(x, 0, sizeof(x))
#define Inf 0x7fffffff
#define MP make_pair
#define PB push_back
#define eps 1e-8
#define pi acos(-1.0)
typedef long long LL;
using namespace std;
double H, D, V;
double R;
double f1(double x){//(R*R - x*x)^(1/2)积分
return 0.5 * (x * sqrt(R*R - x*x) + R*R * asin(x / R));
} double f2(double x){ //x^2*ln(x)积分
return x * x * x * (1.0/ * log(x) - 1.0/);
} double f3(double x){ //x^2*ln(R + (R*R-x*x)^(1/2))积分
double s = sqrt(R*R-x*x);
return 1.0/ * (-*x*x*x-*R*x*s + *R*R*R*atan(x/s) + *x*x*x*log(R + s));
} double volume(double l){
double r = R;
double s1 = f1(r) - f1(l);
double s2 = 0.5 * (f2(r) - f2(l));
double s3 = 0.5 * R * (f1(r) - f1(l));
double s4 = 0.5 * (f3(r) - f3(l));
return H * s1 + (s2 - s3 - s4) * H / R;
} void solve(){
scanf("%lf%lf%lf", &H, &D, &V);
R = D / ;
double l = , r = R, mid;
for (int i = ; i < ; ++i){
mid = (l + r) / ;
if ( * volume(mid) < V) r = mid;
else l = mid;
}
printf("%.5f\n", l + R);
} int main(){
// freopen("a.in", "r", stdin);
// freopen("a.out", "w", stdout);
int cas = ;
scanf("%d", &cas);
while (cas--){
solve();
}
return ;
}
poj3929的更多相关文章
随机推荐
- HDU_1142(最短路 + dfs)
Jimmy experiences a lot of stress at work these days, especially since his accident made working dif ...
- linux中的设备类型
loop设备 loop设备 一.参考命令[root@localhost a]# losetup usage: losetup loop_device ...
- 原生和web交互jsbridge交互总结
技术点:jsbridge. 一: 参数及其意义(代码意义结合支付项目) 二:主动请求原生参数与方法(sendapi) 参数1 判断接口类型 参数2 传递给原生的数据 参数3 回调函数,response ...
- HDU 3407.Zjnu Stadium 加权并查集
Zjnu Stadium Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- [Robot Framework] 动态等待,提供默认的等待时间,等待时间可传可不传
默认10s
- JDK 之 NIO 2 WatchService、WatchKey(监控文件变化)
JDK 之 NIO 2 WatchService.WatchKey(监控文件变化) JDK 规范目录(https://www.cnblogs.com/binarylei/p/10200503.html ...
- Two Sum IV - Input is a BST LT653
Given a Binary Search Tree and a target number, return true if there exist two elements in the BST s ...
- idea15 生成mybatis代码
pom.xml <build> <finalName>mybatis_generator</finalName> <plugins> <plugi ...
- 利用PHPExcel读取excel文件
$filePath = "7788.xls"; $PHPExcel = new PHPExcel(); $PHPReader = new PHPExcel_Reader_Excel ...
- Oracal 学习之用户角色创建分配表空间 给角色分配权限
//创建角色inspur 密码为inspur,默认的表空间为USERS create user inspur identified by inspur default tablespace USERS ...