Number of containers that can be filled in the given time | C # program for the above problem ; Matrix of containers ; Function to find the number of containers that will be filled in X seconds ; Container on top level ; If container gets filled ; Dividing the liquid equally in two halves ; Driver code
using System ; class GFG { static double [ , ] cont = new double [ 1000 , 1000 ] ; static void num_of_containers ( int n , double x ) { int count = 0 ; cont [ 1 , 1 ] = x ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { if ( cont [ i , j ] >= ( double ) 1 ) { count ++ ; cont [ i + 1 , j ] += ( cont [ i , j ] - ( double ) 1 ) / ( double ) 2 ; cont [ i + 1 , j + 1 ] += ( cont [ i , j ] - ( double ) 1 ) / ( double ) 2 ; } } } Console . Write ( count ) ; } public static void Main ( String [ ] args ) { int n = 3 ; double x = 5 ; num_of_containers ( n , x ) ; } }