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 ...
随机推荐
- 关于前端项目cookie的获取
最近项目在做切换,2.0要升级到3.0,遇到跨域问题,使用的是nginx 进行对端口拦截请求其他地址,另外有的服务还要登录权限,之前没看到有这个,后来加上获取cookie的请求 var v3_toke ...
- javascript-初级-day06作用域、JS预解析机制
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...
- SubsamplingScaleImageView 源码解析
一开始没打算分析 SubsamplingScaleImageView 这个开源的图片浏览器的,因为这个库在我们 App 中使用了,觉得自己对这个库还是比较熟悉的,结果某天再看看到源码介绍的时候,才发现 ...
- 图片处理看这篇就完了「GitHub 热点速览 v.21.48」
作者:HelloGitHub-小鱼干 图像处理一直是个实用且热门的研究领域,而本周的 GitHub 项目则多个图像项目上榜.先是勉强和图像处理搭边的渲染引擎 Filament,它能渲染出效果极佳的 3 ...
- Java二次开发海康SDK-对接门禁机
写在最前 SDK版本:CH-HCNetSDKV6.1.6.45_build20210302_win64 参考文档:海康SDK使用手册_V6.1 对接测试设备型号:DS-K1T671M 设备序列号:E5 ...
- DirectX12 3D 游戏开发与实战第六章内容
利用Direct3D绘制几何体 学习目标 探索用于定义.存储和绘制几何体数据的Direct接口和方法 学习编写简单的顶点着色器和像素着色器 了解如何用渲染流水线状态对象来配置渲染流水线 理解怎样创建常 ...
- 【4】蛋白质组学鉴定软件之MSGFPlus
目录 1.简介 2.安装运行 3.结果 1.简介 MSGF+也是近年来应用得比较多的蛋白鉴定软件.java写的,2008年初次发表JPR,2014年升级发表NC,免费开源,持续更新维护,良心软件.而且 ...
- Oracle-创建新表,创建备份表,对表中插入多条数据
一.创建新表 0.基本语法 create table 表名称(id varchar2(50) primary key ,name char(200) not null,phone number(11) ...
- ORACLE中dual用法详解
基本上oracle引入dual为的就是符合语法1. 我们先从名称来说,dual不是缩写词,本身就是完整的单词.dual名词意思是对数,做形容词时是指二重的,二元的.2. Oracle中的dual表是一 ...
- my42_Mysql基于ROW格式的主从同步
模拟主从update事务,从库跳过部分update事务后,再次开始同步的现象 主库 mysql> select * from dbamngdb.isNodeOK; +----+--------- ...