A. Pouring Rain
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.
Output

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.

Examples
input
1 2 3 100
output
NO
input
1 1 1 1
output
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的更多相关文章

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

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

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

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

  3. Codeforces Round #486-F.Rain and Umbrellas题解

    一.题目链接:http://codeforces.com/contest/988/problem/F 二.题面 三.思路 很明显而且比较能想到的$dp$. 四.代码实现 #include<bit ...

  4. CodeForces 988 F Rain and Umbrellas

    Rain and Umbrellas 题意:某同学从x=0的点走到x=a的点,路上有几段路程是下雨的, 如果他需要经过这几段下雨的路程, 需要手上有伞, 每一把伞有一个重量, 求走到重点重量×路程的最 ...

  5. CF667A Pouring Rain 题解

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

  6. Codeforces Round #349

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

  7. BUPT2017 wintertraining(15) #1 题解

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

  8. 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 ...

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

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

随机推荐

  1. XP win2003系统 微软雅黑字体的使用方法

    微软雅黑是微软公司为其新一代操作系统Vista开发的中文字体,据说它将是迄今为止个人电脑上可以显示的最清晰的中文字体.       微软公司表示,在新一代操作系统中为了能够更加清晰的显示文字,目前正在 ...

  2. 点滴积累【C#】---使用log4net组件记录错误日志(以文本形式记录)

    效果: 描述: 利用log4net组件进行错误日志的记录,log4net记录错误的方式我所了解的有4种,No.1 文本形式记录日志,No.2存储到数据库形式记录日志,No.3控制台控制显示日志,No. ...

  3. unity的自带特性

    2016/9/24补充: unity官方有一篇文章对菜单扩展讲的不错 https://unity3d.com/cn/learn/tutorials/topics/interface-essential ...

  4. C#反射取数组单个元素的类型

    去bing上查了一下,果然有和我一样蛋疼的朋友,他们在论坛研究了半天,最后还是暴力解决: public Type GetArrayElementType(Type t) { string tName ...

  5. atitit.  web组件化原理与设计

    atitit.  web组件化原理与设计 1. Web Components提供了一种组件化的推荐方式,具体来说,就是:1 2. 组件化的本质目的并不一定是要为了可复用,而是提升可维护性. 不具有复用 ...

  6. 操作XmlDocument时,出现"System.OutOfMemoryException"异常,如何解决加载大数据的情况?

    System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.at System.St ...

  7. 提高.net程序性能和稳定性-CLR Profile

    CLR Profile能够看到应用程序的内存堆栈情况并且能够查询垃圾回收机制的行为.利用CLR Profile可以确定你的代码哪儿分配了太多内存,从而导致垃圾回收机制的执行,哪些代码长时间的占有内存. ...

  8. STM32F10x_RTC日历

    Ⅰ.概述 接着上一篇文章来讲述关于RTC的计数功能,我们以实例RTC日历(读写年.月.日.星期.时.分.秒)来讲述该章节. STM32F1系列芯片的RTC功能和其他系列(F0.F2.F4等)相比来说, ...

  9. XML序列化和反序列化(C#)

    主要参考资料: http://www.codeproject.com/Articles/483055/XML-Serialization-and-Deserialization-Part-1 http ...

  10. HTML页面中直接加载其他JSP页面

    1.在经典的框架中填充页面时 要填充2处的页面,2处为内容页面,是另外的一个JSP页面 2.左侧页面代码 <%@ page language="java" import=&q ...