题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5954

Problem Description
You have got a cylindrical cup. Its bottom diameter is 2 units and its height is 2 units as well.
The height of liquid level in the cup is d (0 ≤ d ≤ 2). When you incline the cup to the maximal angle such that the liquid inside has not been poured out, what is the area of the surface of the liquid?

Input
The first line is the number of test cases. For each test case, a line contains a float-point number d.

Output
For each test case, output a line containing the area of the surface rounded to 5 decimal places.

Sample Input
4
0
1
2
0.424413182

Sample Output
0.00000
4.44288
3.14159
3.51241

题意:

有一个圆柱形杯子,底部直径为 $2$,高为 $2$,告诉你当杯子水平放置时水面高度为 $d(0 \le d \le 2)$,

求当在水不倒出来的前提下杯子倾斜角度最大时,水面面积。

题解:

(参考https://blog.csdn.net/danliwoo/article/details/53002695

当 $d=1$ 时,是临界情况。

当 $d>1$ 时,水面为一个椭圆,设 $\theta$ 为水面与杯底的夹角,则 $S = \pi R r = \pi \cdot \frac{1}{cos \theta} \cdot 1 = \frac{\pi}{cos \theta}$。

当 $d<1$ 时,水面为一个椭圆截取一部分:

若将水此时的形状,按平行于杯底的方向,分割成若干薄面,每个薄面的面积为 $S_0$,则水的体积为

$V = \int_{0}^{2}S_0dy$;

不难求得

$y_0 = x_0 tan \theta$

$1 + \cos \alpha = x_0$

$S_0 = \pi - \alpha + \sin \alpha \cos \alpha$

上三式,对于 $0 \le \alpha \le \pi$(即 $2 \ge x_0 \ge 0$)均成立。

则水的体积定积分可变为

$V = \int_{0}^{2}(\pi - \alpha + \sin \alpha \cos \alpha)d[(1 + \cos \alpha)\tan\theta]$

$\tan\theta \int_{\pi}^{\alpha_1}(\pi - \alpha + \sin \alpha \cos \alpha)(- \sin \alpha)d\alpha$

其中 $\alpha_1 = \arccos(\frac{2}{\tan\theta}-1)$。

对上式积分得

$V = \tan \theta [(\pi \cos \alpha) + (\sin \alpha - \alpha \cos \alpha) - \frac{1}{3} \sin^3 \alpha]_{\pi}^{\alpha_1}$

那么,我们可以二分 $\theta$,使得 $V$ 逼近 $\pi d$,从而确定 $\theta$,进而用 $S_{斜面} = \frac{S_{底面}}{cos \theta}$ 求得水面面积。

AC代码:

#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-;
inline bool equ(double x,double y){return fabs(x-y)<eps;}
inline double a_t(double t) {
double tmp=2.0/tan(t);
if(tmp>) tmp=2.0;
else if(tmp<) tmp=0.0;
return acos(tmp-1.0);
}
inline double I(double a) {
return pi*cos(a)+sin(a)-a*cos(a)-pow(sin(a),)/3.0;
}
inline double V(double t) {
if(equ(t,pi/2.0)) return ;
else return tan(t)*(I(a_t(t))-I(pi));
}
int main()
{
int T;
double d;
cin>>T;
while(T--)
{
cin>>d;
if(equ(d,))
{
printf("%.5f\n",);
continue;
}
if(d>)
{
printf("%.5f\n",pi/cos(atan(-d)));
continue;
} double l=pi/4.0, r=pi/2.0, t;
while(r-l>eps)
{
t=(l+r)/;
if(equ(V(t),pi*d)) break;
else if(V(t)>pi*d) l=t;
else r=t;
}
double a=a_t(t);
double S=pi-a+sin(a)*cos(a);
printf("%.5f\n",S/cos(t));
}
}

HDU 5954 - Do not pour out - [积分+二分][2016ACM/ICPC亚洲区沈阳站 Problem G]的更多相关文章

  1. HDU 5950 - Recursive sequence - [矩阵快速幂加速递推][2016ACM/ICPC亚洲区沈阳站 Problem C]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5950 Farmer John likes to play mathematics games with ...

  2. HDU 5950 Recursive sequence 【递推+矩阵快速幂】 (2016ACM/ICPC亚洲区沈阳站)

    Recursive sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  3. HDU 5952 Counting Cliques 【DFS+剪枝】 (2016ACM/ICPC亚洲区沈阳站)

    Counting Cliques Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  4. HDU 5948 Thickest Burger 【模拟】 (2016ACM/ICPC亚洲区沈阳站)

    Thickest Burger Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  5. HDU 5949 Relative atomic mass 【模拟】 (2016ACM/ICPC亚洲区沈阳站)

    Relative atomic mass Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  6. hdu 5954 -- Do not pour out(积分+二分)

    题目链接 Problem Description You have got a cylindrical cup. Its bottom diameter is 2 units and its heig ...

  7. 2016ACM/ICPC亚洲区沈阳站H - Guessing the Dice Roll HDU - 5955 ac自动机+概率dp+高斯消元

    http://acm.hdu.edu.cn/showproblem.php?pid=5955 题意:给你长度为l的n组数,每个数1-6,每次扔色子,问你每个串第一次被匹配的概率是多少 题解:先建成ac ...

  8. HDU 5976 Detachment 【贪心】 (2016ACM/ICPC亚洲区大连站)

    Detachment Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  9. HDU 5979 Convex【计算几何】 (2016ACM/ICPC亚洲区大连站)

    Convex Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Subm ...

随机推荐

  1. java Serializable和Externalizable序列化反序列化详解(转载)

    一.什么是序列化? “对象序列化”(Object Serialization)是 Java1.1就开始有的特性. 简单地说,就是可以将一个对象(标志对象的类型)及其状态转换为字节码,保存起来(可以保存 ...

  2. shiny: Web Application Framework for R

    shiny: Web Application Framework for R 基于R语言的一个web框架,适用于数据分析与图表绘画展示类型的网站.

  3. Spring Boot 2.0 整合 FreeMarker 模板引擎

    本篇博文将和大家一起使用Spring Boot 2.0 和FreeMarker 模板引擎整合实战. 1. 创建新的项目 2. 填写项目配置信息 3. 勾选web 模块 4. 勾选freemarker模 ...

  4. etcd 集群运维实践

    etcd 是 Kubernetes 集群的数据核心,最严重的情况是,当 etcd 出问题彻底无法恢复的时候,解决问题的办法可能只有重新搭建一个环境.因此围绕 etcd 相关的运维知识就比较重要,etc ...

  5. Socket网络编程--聊天程序(1)

    很早的一段时间,看了APUE和UNPv1了解了网络编程,但是但是只是看而已,没有具体的实践,趁现在没有什么事做,就来实践了解一下网络编程.写博客保存下来,方便以后用到的时候可以查到. 此次的聊天程序是 ...

  6. 腾讯云快速完成python3.6开发环境搭建与django应用部署

    [本文出自天外归云的博客园] 部署python3.6.5 腾讯云服务器安装python3竟然要3个多小时!而且一度速度为0…… 于是网查据说是腾讯云服务器连python官网缓慢导致的,所以想找个国内的 ...

  7. 【iCore4 双核心板_FPGA】例程六:触发器实验——触发器的使用

    实验现象: 按下按键,绿色led亮灭交互: //--------------------module_rst_n---------------------------// module trigger ...

  8. 【iCore1S 双核心板_FPGA】例程十一:Modelsim仿真实验

    实验现象: 通过仿真波形,分析输入与输出的关系,可以清晰的看到所添加信号波形的变化与程序所写的一致. 核心代码: module modelsim( input CLK_12M, output FPGA ...

  9. 将Java web应用部署到Tomcat 及部署到Tomcat根目录 的三种方式

    Tomcat作为Servlet/JSP容器(服务器)挺不错的,开源免费,需要知道的是Tomcat是一个Web服务器,其符合Servlet/JSP规范,但是却没有实现所有JavaEE规范,所以我们还是应 ...

  10. java-信息安全(十二)-数字签名【Java证书体系实现】

    概述 信息安全基本概念 数字证书 数字证书就是互联网通讯中标志通讯各方身份信息的一串数字,提供了一种在Internet上验证通信实体身份的方式,数字证书不是数字身份证,而是身份认证机构盖在数字身份证上 ...