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 ...
随机推荐
- 流程图(flowchart)语法学习
创建流程图需要选择语言: mermaid流程中的代码包裹graph 这里写顺序end流程图方向:从上到下(TB),从下到上(BT),从左到右(LR),从右到左(RL) TB - 从上到下TD - 自上 ...
- 性能压测-压力测试-Apache JMeter安装使用
http://jmeter.apache.org/download_jmeter.cgi 下载win10得zip文件 在有java环境后进入项目得bin->jmeter.bat 启动 自带国际化 ...
- git新手配置(windows环境)
windows环境,初步了解git是个什么东西,使用过svn相关软件最佳,否则可以先补一下git的相关概念和用处,相关教程:https://www.liaoxuefeng.com/wiki/89604 ...
- Protocol Buffer序列化Java框架-Protostuff
了解Protocol Buffer 首先要知道什么是Protocol Buffer,在编程过程中,当涉及数据交换时,我们往往需要将对象进行序列化然后再传输.常见的序列化的格式有JSON,XML等,这些 ...
- 【2020五校联考NOIP #7】道路扩建
题面传送门 题意: 给出一张 \(n\) 个点 \(m\) 条边的无向图 \(G\),第 \(i\) 条边连接 \(u_i,v_i\) 两个点,权值为 \(w_i\). 你可以进行以下操作一次: 选择 ...
- Linux搭建rsync备份服务器备份
环境: 1台rsync备份服务器,IP:10.0.0.188 1台rsync备份客户端,IP:10.0.0.51 备份数据需注意: 1. 在业务低谷时间进行备份 2. 进行备份限速 一.搭建rsync ...
- mongodb数据库简单类
<?php/*** Mongodb类** examples: * $mongo = new HMongodb("127.0.0.1:11223"); * $mongo-> ...
- OpenSSH 密码和公钥认证原理探究
目录 配置和保护SSH H3 - 使用SSH 访问远程命令行 H4 - 什么是OpenSSH ? H4 - 登录方式: H4 - 登录并执行临时命令: H4 - 查看登录用户 H4 - 登录原理 密码 ...
- C/C++ Qt StandardItemModel 数据模型应用
QStandardItemModel 是标准的以项数据为单位的基于M/V模型的一种标准数据管理方式,Model/View 是Qt中的一种数据编排结构,其中Model代表模型,View代表视图,视图是显 ...
- 学习java 7.21
学习内容: 模块使用 AWT是窗口框架 它从不同平台的窗口系统中抽取出共同组件,当程序运行时,将这些组件的创建和动作委托给程序所在的运行平台.简而言之,当使用AWT编写图形界面应用时,程序仅指定了界面 ...