CF667A Pouring Rain 题解
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 题解的更多相关文章
- CodeForces 667A Pouring Rain
A. Pouring Rain time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- codeforces 667A A. Pouring Rain(水题)
题目链接: A. Pouring Rain time limit per test 1 second memory limit per test 256 megabytes input standar ...
- [Codeforces667A]Pouring Rain(数学,几何)
题目链接:http://codeforces.com/contest/667/problem/A 题意:一个杯子里有水,一个人在喝并且同时在往里倒.问这个人能不能喝完,多久能喝完. 把相关变量都量化成 ...
- BUPT2017 wintertraining(15) #1 题解
拖了一周才完成的题解,抛出一个可爱的表情 (っ'-')╮ =͟͟͞͞❤️.对我来说E.F比较难,都是线段树的题,有点久没写了. A - Infinite Sequence CodeForces - 6 ...
- Codeforces Round #349
终于又回到熟悉的Round了 数学 A - Pouring Rain 设个未知数,解方程,还好没有hack点 #include <bits/stdc++.h> typedef long l ...
- 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 ...
- 《三体》刘慈欣英文演讲:说好的星辰大海你却只给了我Facebook
美国当地时间2018日11月8日,著名科幻作家刘慈欣被授予2018年度克拉克想象力贡献社会奖(Clarke Award for Imagination in Service to Society),表 ...
- 【题解】【直方图】【Leetcode】Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...
- [LeetCode]题解(python):042-Trapping Rain Water
题目来源 https://leetcode.com/problems/trapping-rain-water/ Given n non-negative integers representing a ...
随机推荐
- Assassin暗杀者-自用短小精悍的webshell管理工具分享
Assassin Assassin是一款精简的基于命令行的webshell管理工具,它有着多种payload发送方式和编码方式,以及精简的payload代码,使得它成为隐蔽的暗杀者,难以被很好的防御. ...
- 【Tool】IDEA功能--SVN和Git
IDEA功能--SVN和Git 2019-11-08 21:12:22 by冲冲 1.IDEA的SVN (1)提交项目代码到SVN服务器 ① 指定不用上传的目录 ② 设置项目上传的路径 SVN服务 ...
- 论文翻译:2020_Densely connected neural network with dilated convolutions for real-time speech enhancement in the time domain
提出了模型和损失函数 论文名称:扩展卷积密集连接神经网络用于时域实时语音增强 论文代码:https://github.com/ashutosh620/DDAEC 引用:Pandey A, Wang D ...
- Java LinkedList小记
1. 基本用法 LinkedList实现了List.Deque.Queue接口,可以按照队列.栈和双端队列的方式进行操作.LinkedList有两个构造方法,一个是默认构造,另一个接受Collecti ...
- 《手把手教你》系列技巧篇(四十五)-java+ selenium自动化测试-web页面定位toast-上篇(详解教程)
1.简介 在使用appium写app自动化的时候介绍toast的相关元素的定位,在Web UI测试过程中,也经常遇到一些toast,那么这个toast我们这边如何进行测试呢?今天宏哥就分两篇介绍一下. ...
- c语言printf输出最前端字符不显示
原因:语法错误,和其它语言语法混用. printf("链表长度 : %d \n",length); printf("length is : %d \n",len ...
- pcm-pcie 解析
简介 pcm 全称为 Performance Counter Monitor,该项目是针对 intel 平台处理器的资源利用率进行监控的工具.在现代 Intel 处理器已经提供了监视处理器内部性能事件 ...
- pyyaml模块
pyyaml模块是一种文件数据处理格式的方法,常用与生成.解析或修改.yaml配置文件 1.常见.yaml文件格式内容如下 languages: - Ruby - Perl - Python webs ...
- nginx二级域名指向不同文件项目配置
需要使用泛域名解析, 并且加上空的判断,以保证没有二级域名的也可以访问 核心配置 server_name ~^(?<subdomain>.+)\.caipudq\.cn$;if ( $su ...
- A Child's History of England.43
PART THE SECOND When the King heard how Thomas à Becket had lost his life in Canterbury Cathedral, t ...