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的更多相关文章
随机推荐
- Andriod ----配置环境变量
注意:跟java相关的目录不要有中文和空格. 1.打开我的电脑--属性--高级--环境变量 2.新建系统变量JAVA_HOME 和CLASSPATH 变量名:JAVA_HOME 变量值:D:\Java ...
- 在IP网络中,P、PE、CE代表意思
1.ce , pe属于mpls vpn里的概念.VPN概念中,把整个网络中的路由器分为三类:用户边缘路由器(CE).运营商边缘路由器(PE)和运营商骨干路由器(P):其中,PE充当IP VPN接入路由 ...
- N! (数组)
#include <iostream> using namespace std; ; int f[MAXN]; int main(){ int n; cin >> n; f[] ...
- BZOJ2330或洛谷3275 [SCOI2011]糖果
BZOJ原题链接 洛谷原题链接 很明显的差分约束,但数据范围较大,朴素\(SPFA\)判正环求解会\(T\)(理论上如此,但我看到有挺多人用朴素的还跑得挺快..),所以需要优化. 我们所建立的有向图中 ...
- mysql 5.17 的update失败问题
在使用workbench的时候,写入update语句,会很提现失败,原因是安全模式; 可能是workbench在数据库更新的时候是有限制的,防止错误哦l 更改方法也很简单; Edit - Profer ...
- BZOJ 1227 [SDOI2009]虔诚的墓主人 - 扫描线
Solution 离散化 扫描线, 并用 $rest[i]$ 和 $cnt[i]$ 记录 第$i$列 总共有 $cnt[i]$棵常青树, 还有$rest[i]$ 没有被扫描到. 那么 第$i$ 列的方 ...
- 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 ...
- 利用PHP脚本辅助MySQL数据库管理1-表结构
<?php $dbi = new DbMysql; $dbi->dbh = 'mysql://root:mysql@127.0.0.1/coffeetest'; $map = array( ...
- Mac 环境通用
mac 下更新 .bash_profile 文件 1.打开terminal(终端) 2.cd ~ ( 进入当前用户的home目录) 3.open .bash_profile (打开.bash_prof ...
- 数的划分(NOIP2001&水题测试2017082401)
题目链接:数的划分 这题直接搜索就行了.给代码,思路没什么好讲的,要讲的放在代码后面: #include<bits/stdc++.h> using namespace std; int d ...