Given a cylinder glass with diameter equals D centimeters. The initial level of water in the glass equals H centimeters from the bottom. You drink the water with a speed of M milliliters per second. But if you do not drink the water from the glass, the level of water increases by N centimeters per second. The task is to find the time required to make the glass empty or find if it is possible to make the glass empty or not.
Input: D = 1, H = 1, M = 1, N = 1
Input: D = 1, H = 2, M = 3, N = 100
Approach: This is a Geometry question. It is known that the area of the glass is pie * r2 where r represents the radius i.e. (D / 2). So to find the rate at which the water is being consumed per second, divide the volume given (it is known that 1 milliliter equals 1 cubic centimeter) with the area.
If the value is less than the rate at which the water is being poured in the glass, if it is not being drunk then the answer will be No else the glass can be empty.
To find the time, divide h / (v / (pie * r2) – e) and that is the time when the glass will become empty.
Below is the implementation of the above approach:
- Program to find amount of water in a given glass
- Program to find the rate percentage from compound interest of consecutive years
- Maximum sum of cocktail glass in a 2D matrix
- Count of a, b & c after n seconds for given reproduction rate
- Sum of values of all possible non-empty subsets of the given array
- Product of values of all possible non-empty subsets of given Array
- Number of ways of distributing N identical objects in R distinct groups with no groups empty
- Find the value of f(n) / f(r) * f(n-r)
- Find 2^(2^A) % B
- Find the value of max(f(x)) - min(f(x)) for a given F(x)
- Find value of (n^1 + n^2 + n^3 + n^4) mod 5 for given n
- Find value of (1^n + 2^n + 3^n + 4^n ) mod 5
- Find K such that |A - K| = |B - K|
- Find (1^n + 2^n + 3^n + 4^n) mod 5 | Set 2
- Find maximum among x^(y^2) or y^(x^2) where x and y are given
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.