题意:

如上图放置的一个圆锥,告诉你从圆锥顶的洞中流出多少体积的水,求现在水面高度。。

思路:

无聊时做的一道题,实际上就是一道高数题,重积分,可惜我高数本来也不好而且还忘光了,积了很久,而且错了很多遍。。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的更多相关文章

随机推荐

  1. Centos7 开机启动命令行模式

    1.在图形界面下单击鼠标右键,选择“Konsole”: 2. 获取当前系统启动模式,输入:systemctl get-default 3.查看配置文件, cat /etc/inittab 4.通过以上 ...

  2. UIDataPicker 时间选择器

    自用时间选择器 @interface ViewController () { UILabel *cityLabel; UIDatePicker *datePicker; } //@property(n ...

  3. PHP学习笔记(一)

    1.什么是 PHP? PHP 指 PHP:超文本预处理器(译者注:PHP: Hypertext Preprocessor,递归命名) PHP 是一种服务器端的脚本语言,类似 ASP PHP 脚本在服务 ...

  4. Raw Socket(原始套接字)实现Sniffer(嗅探)

    参考资料: https://www.xuebuyuan.com/3190946.html https://blog.csdn.net/zxygww/article/details/52093308 i ...

  5. Writing modular applications with laravel-modules

    01-07-2016 Let me start by saying Laravel is an amazing framework. However when it comes to writing ...

  6. 高级设计总监的设计方法论——5W1H需求分析法 KANO模型分析法

    本期开始进入设计方法论的学习,大湿自己也是边学边分享,算是巩固一遍吧: 另外这些理论基本都是交叉结合来应用于工作中,我们学习理论但不要拘泥于理论的框架中,掌握后要灵活运用一点- 这些理论一部分来自于我 ...

  7. base64编码是什么

    首先明确一点base64 是一种编码格式.就想utf-8一样,能在电脑上表示所有字符,或者换句话说通过编码能让电脑理解你想要标识的字符(因为电脑只知道0和1 ) 就像ascII 中 0100 0001

  8. Linux日志文件总管——logrotate

    日志文件包含了关于系统中发生的事件的有用信息,在排障过程中或者系统性能分析时经常被用到.对于忙碌的服务器,日志文件大小会增长极快,服务器会很快消耗磁盘空间,这成了个问题.除此之外,处理一个单个的庞大日 ...

  9. AJAX-php-json数组

    1.在php中有个数组,响应回前端 $array=["习大大","川普","金三胖"];2.JS对象数据格式 ex: 数组: var TOM ...

  10. 用python实现数学多元数学方程式计算

    题目:公鸡5元钱一只,母鸡3元钱一只,小鸡3只一块钱,其中公鸡,母鸡,小鸡都必须有,问公鸡,母鸡,小鸡各买多少只刚好凑足100元钱? 一:数学算术分析: x+y+z=100 5x+3y+z/3=100 ...