Content

一个水桶直径为 \(d\) 厘米,初始时水面高度为 \(h\) 厘米。你每秒钟喝 \(v\) 毫升水,而由于下雨,水桶里面的水在不喝水的时候每秒会上升 \(e\) 厘米。求你最少需要多少秒才能喝完水桶里面的水,或者你喝水的速度赶不上水桶里面的水增多的速度。

数据范围:\(1\leqslant d,h,v,e\leqslant 10^4\)。

Solution

我们都知道,圆柱的底面积 \(S=\pi r^2=\pi(\dfrac{d}{2})^2=\dfrac{\pi d^2}{4}\),那么原来水的体积 \(V=Sh=\dfrac{\pi d^2h}{4}\)。

由于这里说的是水桶里的水每秒上升的高度,所以我们需要转化成体积为 \(\dfrac{\pi d^2e}{4}\)。然后我们在拿这个和 \(v\) 比较,如果 \(v\leqslant \dfrac{\pi d^2e}{4}\),那么你喝水的速度赶不上水桶里面的水增多的速度,不能喝完里面的水,否则答案就是 \(\dfrac{\dfrac{\pi d^2h}{4}}{v-\dfrac{\pi d^2e}{4}}=\dfrac{\dfrac{\pi d^2h}{4}}{\dfrac{4v-\pi d^2e}{4}}=\dfrac{\pi d^2h}{4v-\pi d^2e}=\dfrac{h}{\dfrac{4v}{\pi d^2}-e}\)。

Code

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std; const double pi = acos(-1.0);
double d, h, v, e; int main() {
scanf("%lf%lf%lf%lf", &d, &h, &v, &e);
if(v <= d * d / 4.0 * pi * e) return printf("NO"), 0;
printf("YES\n%.12lf", h / (4.0 * v / (pi * d * d) - e));
return 0;
}

CF667A Pouring Rain 题解的更多相关文章

  1. CodeForces 667A Pouring Rain

    A. Pouring Rain time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  2. codeforces 667A A. Pouring Rain(水题)

    题目链接: A. Pouring Rain time limit per test 1 second memory limit per test 256 megabytes input standar ...

  3. [Codeforces667A]Pouring Rain(数学,几何)

    题目链接:http://codeforces.com/contest/667/problem/A 题意:一个杯子里有水,一个人在喝并且同时在往里倒.问这个人能不能喝完,多久能喝完. 把相关变量都量化成 ...

  4. BUPT2017 wintertraining(15) #1 题解

    拖了一周才完成的题解,抛出一个可爱的表情 (っ'-')╮ =͟͟͞͞❤️.对我来说E.F比较难,都是线段树的题,有点久没写了. A - Infinite Sequence CodeForces - 6 ...

  5. Codeforces Round #349

    终于又回到熟悉的Round了 数学 A - Pouring Rain 设个未知数,解方程,还好没有hack点 #include <bits/stdc++.h> typedef long l ...

  6. English trip V1 - B 4.How Do You Make a Salad? 请给我一间房? Teacher:Julia Key:imperatives 祈使句

    In this lesson you will learn to give instructions. 这节课你将将学会给出指示. 课上内容(Lesson) 词汇(Key Word ) bell pe ...

  7. 《三体》刘慈欣英文演讲:说好的星辰大海你却只给了我Facebook

    美国当地时间2018日11月8日,著名科幻作家刘慈欣被授予2018年度克拉克想象力贡献社会奖(Clarke Award for Imagination in Service to Society),表 ...

  8. 【题解】【直方图】【Leetcode】Trapping Rain Water

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  9. [LeetCode]题解(python):042-Trapping Rain Water

    题目来源 https://leetcode.com/problems/trapping-rain-water/ Given n non-negative integers representing a ...

随机推荐

  1. 干掉idea视图黄色警告

    最近在写jsp代码黄色很烦人,安装codeglance插件小地图感觉也是很不舒服 ,百度了一下可以取消警告: https://blog.csdn.net/qq_40634961/article/det ...

  2. Redis概述以及Linux安装

    Redis 概述 Redis是什么 Redis,Remote Dictionary Server,远程字典服务.是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.key-v ...

  3. Codeforces 690A2 - Collective Mindsets (medium)

    Codeforces 题面传送门 & 洛谷题面传送门 一道脑筋急转弯的结论题. 首先我们考虑对于某个特定的金币数 \(m\),有哪些 \(n\) 满足条件.考虑最 naive 的情况,\(m= ...

  4. 洛谷 P6030 - [SDOI2012]走迷宫(高斯消元+SCC 缩点)

    题面传送门 之所以写个题解是因为题解区大部分题解的做法都有 bug(u1s1 周六上午在讨论区里连发两个 hack 的是我,由于我被禁言才让 ycx 代发的) 首先碰到这种期望题,我们套路地设 \(d ...

  5. 【机器学习与R语言】5-规则学习算法

    目录 1.分类规则原理 1.1 1R单规则算法 1.2 RIPPER算法 2. 规则学习应用示例 1)收集数据 2)探索和准备数据 3)训练数据 4)评估性能 5)提高性能 6)选择决策树中的分类规则 ...

  6. 【ThermoRawFileParser】质谱raw格式转换mgf

    众所周知,Proteowizard MSconvert用于质谱原始数据的格式转换,但主要平台是windows,要想在Linux上运行需要打Docker或Wine,对于普通用户来说还是很困难的,想想质谱 ...

  7. 数据库(database)介绍

    0.数据定义:除了文本类型的数据,图像.音乐.声音都是数据. 数据分类:结构化数据.非结构化数据.1.数据库定义:"电子化的文件柜","数据仓库".数据库是一个 ...

  8. FFmpeg笔记:使用MSVC工具链编译Windows版本静态库、动态库

    2019年3月开始,为了将音视频编解码功能集成到Cocos2d-x中,开始接触到FFmpeg: 当时开发环境还在Mac下,编译FFmpeg相比现在用Windows平台要方便的多: 最近,公司内部有个U ...

  9. Office2020-2021 离线安装教程

    首先:先安装两个 net .再安装 office 如下: DownFile:https://pan.baidu.com/s/19iykxwofXK36wWY5w4GVFg  codenum:6666

  10. 巩固javaweb第十八天

    提交按钮 只要涉及提交信息,都应该提供一个提交按钮,当点击提交按钮的时候,用户输入的 信息将提交给服务器,意味着输入过程的结束.注册界面中也包含一个提交按钮. 提交按钮的基本格式如下: <inp ...