codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

667A.md (3153B)


      1 Source: https://codeforces.com/problemset/problem/667/A
      2 
      3 A. Pouring Rain
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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.
     24 
     25 Thus, your cup is a cylinder with diameter equals *d* centimeters. Initial level of water in cup equals *h* centimeters from the bottom.
     26 
     27  ![](https://espresso.codeforces.com/a2b45bca69db9e4654739b50d435d575602fcafb.png) 
     28 
     29 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.
     30 
     31 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.
     32 
     33 Note one milliliter equals to one cubic centimeter.
     34 
     35 Input
     36 
     37 The only line of the input contains four integer numbers *d*, *h*, *v*, *e* (1 ≤ *d*, *h*, *v*, *e* ≤ 104), where:
     38 
     39 * *d* — the diameter of your cylindrical cup,
     40 * *h* — the initial level of water in the cup,
     41 * *v* — the speed of drinking process from the cup in milliliters per second,
     42 * *e* — the growth of water because of rain if you do not drink from the cup.
     43 
     44 Output
     45 
     46 If it is impossible to make the cup empty, print "NO" (without quotes).
     47 
     48 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.
     49 
     50 Examples
     51 
     52 Input
     53 
     54 ```
     55 1 2 3 100
     56 ```
     57 
     58 Output
     59 
     60 ```
     61 NO
     62 ```
     63 
     64 Input
     65 
     66 ```
     67 1 1 1 1
     68 ```
     69 
     70 Output
     71 
     72 ```
     73 YES  
     74 3.659792366325
     75 ```
     76 
     77 Note
     78 
     79 In the first example the water fills the cup faster than you can drink from it.
     80 
     81 In the second example area of the cup's bottom equals to ![](https://espresso.codeforces.com/419dc74dcd7bc392019c9fe748fe1fdb08ab521a.png), thus we can conclude that you decrease the level of water by ![](https://espresso.codeforces.com/e8edb237e1f805fe83c2f47e48d3a9d03f2ee304.png) centimeters per second. At the same time water level increases by 1 centimeter per second due to rain. Thus, cup will be empty in ![](https://espresso.codeforces.com/9dae615d7e2c5c7c03cb478848fb06aba1a8942e.png) seconds.