CodeForces 667A Pouring Rain
1 second
256 megabytes
standard input
standard output
A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition — when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness,
think about big deeds you have to do.
Today everything had changed quietly. You went on the street with a cup contained water, your favorite drink. In a moment when you were drinking a water you noticed that the process became quite long: the cup still contained water because of rain. You decided
to make a formal model of what was happening and to find if it was possible to drink all water in that situation.
Thus, your cup is a cylinder with diameter equals d centimeters. Initial level of water in cup equals h centimeters
from the bottom.

You drink a water with a speed equals v milliliters per second. But rain goes with such speed that if you do not drink a water from
the cup, the level of water increases on e centimeters per second. The process of drinking water from the cup and the addition of
rain to the cup goes evenly and continuously.
Find the time needed to make the cup empty or find that it will never happen. It is guaranteed that if it is possible to drink all water, it will happen not later than after 104 seconds.
Note one milliliter equals to one cubic centimeter.
The only line of the input contains four integer numbers d, h, v, e (1 ≤ d, h, v, e ≤ 104),
where:
- d — the diameter of your cylindrical cup,
- h — the initial level of water in the cup,
- v — the speed of drinking process from the cup in milliliters per second,
- e — the growth of water because of rain if you do not drink from the cup.
If it is impossible to make the cup empty, print "NO" (without quotes).
Otherwise print "YES" (without quotes) in the first line. In the second line print a real number — time in seconds needed the cup will be empty. The answer
will be considered correct if its relative or absolute error doesn't exceed 10 - 4.
It is guaranteed that if the answer exists, it doesn't exceed 104.
1 2 3 100
NO
1 1 1 1
YES 3.659792366325#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <stdio.h> using namespace std;
double d,h,v,e;
int main()
{
scanf("%lf%lf%lf%lf",&d,&h,&v,&e);
double pi=2*asin(1.0);
double ve=pi*(d/2)*(d/2)*e;
double v1=pi*(d/2)*(d/2)*h;
if(v<=ve)
{printf("NO\n");return 0;}
else
{
printf("YES\n");
printf("%lf\n",v1/(v-ve));
return 0;
} }
CodeForces 667A Pouring Rain的更多相关文章
- 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 题意:一个杯子里有水,一个人在喝并且同时在往里倒.问这个人能不能喝完,多久能喝完. 把相关变量都量化成 ...
- Codeforces Round #486-F.Rain and Umbrellas题解
一.题目链接:http://codeforces.com/contest/988/problem/F 二.题面 三.思路 很明显而且比较能想到的$dp$. 四.代码实现 #include<bit ...
- CodeForces 988 F Rain and Umbrellas
Rain and Umbrellas 题意:某同学从x=0的点走到x=a的点,路上有几段路程是下雨的, 如果他需要经过这几段下雨的路程, 需要手上有伞, 每一把伞有一个重量, 求走到重点重量×路程的最 ...
- CF667A Pouring Rain 题解
Content 一个水桶直径为 \(d\) 厘米,初始时水面高度为 \(h\) 厘米.你每秒钟喝 \(v\) 毫升水,而由于下雨,水桶里面的水在不喝水的时候每秒会上升 \(e\) 厘米.求你最少需要多 ...
- Codeforces Round #349
终于又回到熟悉的Round了 数学 A - Pouring Rain 设个未知数,解方程,还好没有hack点 #include <bits/stdc++.h> typedef long l ...
- BUPT2017 wintertraining(15) #1 题解
拖了一周才完成的题解,抛出一个可爱的表情 (っ'-')╮ =͟͟͞͞❤️.对我来说E.F比较难,都是线段树的题,有点久没写了. A - Infinite Sequence CodeForces - 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 ...
- 《三体》刘慈欣英文演讲:说好的星辰大海你却只给了我Facebook
美国当地时间2018日11月8日,著名科幻作家刘慈欣被授予2018年度克拉克想象力贡献社会奖(Clarke Award for Imagination in Service to Society),表 ...
随机推荐
- php_memcahed 安装
1.下载服务端memcached软件 32bit:下载 memcached-win32-1.4.4-14.zip(直接下)里面包含6个文件,将解压后的文件夹随便放在什么位置(例如:D:\wamp_wi ...
- jmeter测试http请求使用csv参数
创建参数化文件 线程组添加CSV Data Set Config配置元件 为请求添加参数 重新运行查看结果 使用随机参数(JMeter有好多函数可以使用) 查看结果发现使用随机生成的数字 3
- 智能指针tr1::shared_ptr、boost::shared_ptr使用
对于tr1::shared_ptr在安装vs同一时候会自带安装,可是版本号较低的不存在.而boost作为tr1的实现品,包括 "Algorithms Broken Compiler Work ...
- [k8s]kubectl windows配置(kubernetic) && kubectl config set-context使用Kubernetic
参考: https://feisky.gitbooks.io/kubernetes/components/kubectl.html https://kubernetes.io/docs/tasks/t ...
- 2015·Fool's Day·NND
本博文没有主旨,仅仅是记录. ============================ Date:2015/4/1 - April Fool's Day! Addr:ZhongHai ======== ...
- Pedometer_forAndroid
https://github.com/Nicky213Zhang/Pedometer_forAndroid 自行封装了一个计步器控件,采用:计步传感器Sensor.TYPE_STEP_COUNTER计 ...
- 使用 Bolt 实现 GridView 表格控件
用 Bolt 实现了一个表格控件: 1. 提供 Insert,Remove,Get,Set 接口,可以为表格增删数据: 2. 通过 ItemClass, ItemSetDataFunc 属性来指定显 ...
- NerdTree 学习
http://www.jianshu.com/p/eXMxGx--------------来自大神到博客 到现在为止我仍然不能设置<F2>开启和隐藏目录树.sangxin.
- 跟着百度学PHP[14]-PDO的错误处理模式&PDO执行SQL
我们在使用PDO去执行sql语句的时候并不会报错.如下案例所示: <?php try { //$pdo = new pdo("mysql:host=主机;port=端口;dbname= ...
- The Definitive Guide To Django 2 学习笔记(三) URLconfs 和松耦合
前面的例子体现了一个设计模式中的重要思想,松耦合. 不论我们是将/time/改成/current_time/,还是新建一个/another-time-page/同样指向views.py中的 curre ...