题意:

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

思路:

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

    原题链接 虽然依旧是套模板,但是因为我太弱了,不会建状态,所以去看了题解.. 这里就直接引用我看的题解吧,写的不错的. 题解 //我的代码 #include<cstdio> #includ ...

  2. Telnet远程登录

    假设 电脑A Telnet远程登录 电脑B (Windows) 1.电脑B: 关闭防火墙 开启Telnet服务:“我的电脑”-->“管理”-->“服务”-->Telnet开启 2.电 ...

  3. System.Runtime.InteropServices.COMException: 检索 COM 类工厂中 CLSID 为 {0002E510-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 80040154

    这个问题困恼我好几天了,今天终于解决. 开始我在网上左百度右google,都没搜到最终的解决方案,今天我把解决方案贴出来,以供大家分享! 网上有些是报80070005错误的,跟我这个80040154错 ...

  4. canvas和图片互转

    原文:http://www.jb51.net/html5/160920.html 这么神奇么?先记录一下. 使用JavaScript将图片拷贝进画布 要想将图片放入画布里,我们使用canvas元素的d ...

  5. navigator - 定时器 - event

    1. navigator userAgent: 包含浏览器名称,内核,版本号的字符串 鄙视: 如何判断浏览器名称和版本号 2. 定时器: 2种: 1. 周期性定时器: 什么是: 让程序每隔一段时间间隔 ...

  6. day14(内置函数)

    print(list(map(func, lambda x : x)) print(list(filter lambda x : x > len(x))) print(zip(l1,l2,tu) ...

  7. ThinkPHP getBy动态查询

    getBy动态查询 ThinkPHP getBy动态查询是一个魔术方法,可以根据某个字段名称动态得到对应的一条数据记录. 根据用户名(username)查询对应的用户资料记录: public func ...

  8. DevExpress 只允许修改指定列

    gridView1.OptionsBehavior.Editable = true; gridView1.OptionsBehavior.ReadOnly = false; foreach (Grid ...

  9. 菜品识别 API调用

    #get_access_token.py #获取access_token 1 import requests def GetToken(API_KEY,SECRET_KEY): url = 'http ...

  10. mongodb知识积累

    1: 安装mongodb https://www.cnblogs.com/zhangdaicong/p/7492494.html 2:配置文件 vi /etc/mongodb.conf https:/ ...