首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >CodeForces 667A Pouring Rain

CodeForces 667A Pouring Rain

作者头像
ShenduCC
发布于 2018-04-26 09:15:11
发布于 2018-04-26 09:15:11
1.1K00
代码可运行
举报
文章被收录于专栏:算法修养算法修养
运行总次数:0
代码可运行

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

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
1 2 3 100

output

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
NO

input

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
1 1 1 1

output

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
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;
    }

}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016-05-02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
HDUOJ-------2493Timer(数学 2008北京现场赛H题)
Timer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 445    Accepted Submission(s): 90 Problem Description Recently, some archaeologists discovered an ancient relic on a small island in the Pacif
Gxjun
2018/03/22
6350
HDUOJ-------2493Timer(数学 2008北京现场赛H题)
HDU 2289 Cup【高精度,二分】
Cup Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8942    Accepted Submission(s): 2744 Problem Description The WHU ACM Team has a big cup, with which every member drinks water. Now, we know th
Angel_Kitty
2018/04/09
5740
Codeforces Round #460 (Div. 2)-A Supermaket(贪心)
We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that a yuan for b kilos (You don't need to care about what "yuan" is), the same as a / b yuan for a kilo.
风骨散人Chiam
2020/10/28
3360
Codeforces 626G Raffles(贪心+线段树)
G. Raffles time limit per test:5 seconds memory limit per test:256 megabytes input:standard input output:standard output Johnny is at a carnival which has n raffles. Raffle i has a prize with value pi. Each participant can put tickets in whichever raffles
Angel_Kitty
2018/04/09
5470
Codeforces 626G Raffles(贪心+线段树)
CF思维联系– Codeforces-988C Equal Sums (哈希)
这个题,无论怎么循环都是超时的,所以必须想到一种不需要循环的方法,这里我用的是hash,因为是每个序列删掉一个之后相等,那我们就保存删掉一个数之后的值,用hash存起来,如果再遇到而且不是同一个序列的话,那就是可以构造出提要求的两个序列。
风骨散人Chiam
2020/11/03
6220
CodeForces 157B Trace
B. Trace time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day, as Sherlock Holmes was tracking down one very important criminal, he found a wonderful painting on the wall. This w
ShenduCC
2018/04/26
1.2K0
codeforce 1311E. Construct the Binary Tree (构造,就是个模拟)
ACM思维题训练集合 You are given two integers n and d. You need to construct a rooted binary tree consisting of n vertices with a root at the vertex 1 and the sum of depths of all vertices equals to d.
风骨散人Chiam
2020/10/29
4060
codeforce 1311E. Construct the Binary Tree (构造,就是个模拟)
Codeforces 626D Jerry's Protest(暴力枚举+概率)
D. Jerry's Protest time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds. In each round, Andrew and
Angel_Kitty
2018/04/09
6790
Codeforces 626D Jerry's Protest(暴力枚举+概率)
Codeforces 839E Mother of Dragons【__builtin_popcount()的使用】
E. Mother of Dragons time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output There are n castles in the Lannister's Kingdom and some walls connect two castles, no two castles are connected by more than
Angel_Kitty
2018/04/09
8090
Codeforces 839E Mother of Dragons【__builtin_popcount()的使用】
Codeforces Round #624 (Div. 3) C - Perform the Combo
You want to perform the combo on your opponent in one popular fighting game. The combo is the string ss consisting of nn lowercase Latin letters. To perform the combo, you have to press all buttons in the order they appear in ss. I.e. if s=s="abca" then you have to press 'a', then 'b', 'c' and 'a' again.
glm233
2020/09/28
6760
cf------(round)#1 C. Ancient Berland Circus(几何)
C. Ancient Berland Circus time limit per test 2 seconds memory limit per test 64 megabytes input standard input output standard output Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were differen
Gxjun
2018/03/22
6480
Codeforces Round #408 (Div. 2)(A.水,B,模拟)
A. Buying A House time limit per test:2 seconds memory limit per test:256 megabytes input:standard i
Angel_Kitty
2018/04/08
6980
Codeforces Round #408 (Div. 2)(A.水,B,模拟)
CodeForces 639 A
Bear and Displayed Friends time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his
ShenduCC
2018/04/26
5650
HDU 5144 NPY and shot(物理运动学+三分查找)
NPY and shot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1035    Accepted Submission(s): 428 Problem Description NPY is going to have a PE test.One of the test subjects is throwing the shot.The
Angel_Kitty
2018/04/08
4970
CodeForces - 260B
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
风骨散人Chiam
2020/10/28
3310
hdu------2488Tornado(几何)
Tornado Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 196    Accepted Submission(s): 48 Problem Description Professor Jonathan is a well-known Canadian physicist and meteorologist. People who kn
Gxjun
2018/03/22
6710
Codeforces Round #300(A.【字符串,多方法】,B.【思维题】,C.【贪心,数学】)
A. Cutting Banner time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami beach.
Angel_Kitty
2018/04/09
9380
【CodeForces 589F】Gourmet and Banquet(二分+贪心或网络流)
A gourmet came into the banquet hall, where the cooks suggested n dishes for guests. The gourmet knows the schedule: when each of the dishes will be served.
饶文津
2020/06/02
2870
Codeforces 1291 Round #616 (Div. 2) B
B. Array Sharpening time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output You’re given an array a1,…,an of n non-negative integers.
风骨散人Chiam
2020/10/29
8930
Codeforces 727D-T-shirts Distribution (字符串 贪心)
The organizers of a programming contest have decided to present t-shirts to participants. There are six different t-shirts sizes in this problem: S, M, L, XL, XXL, XXXL (sizes are listed in increasing order). The t-shirts are already prepared. For each size from S to XXXL you are given the number of t-shirts of this size.
glm233
2020/09/28
6170
相关推荐
HDUOJ-------2493Timer(数学 2008北京现场赛H题)
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验