Find if the glass will be empty or not when the rate of drinking is given | C ++ implementation of the approach ; Function to return the time when the glass will be empty ; Check the condition when the glass will never be empty ; Find the time ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; double pie = 3.1415926535897 ; double findsolution ( double d , double h , double m , double n ) { double k = ( 4 * m ) / ( pie * d * d ) ; if ( n > k ) return -1 ; double ans = ( h / ( k - n ) ) ; return ans ; } int main ( ) { double d = 1 , h = 1 , m = 1 , n = 1 ; cout << findsolution ( d , h , m , n ) ; return 0 ; }