Count of triples ( A , B , C ) where A * C is greater than B * B | Counts the number of triplets for a given value of b ; Count all triples in which a = i ; Smallest value j such that i * j > B2 ; Count all ( i , B2 , x ) such that x >= j ; count all ( x , B2 , y ) such that x >= j this counts all such triples in which a >= j ; As all triples with a >= j have been counted reduce A to j - 1. ; Counts the number of triples that satisfy the given constraints ; GetCount of triples in which b = i ; Driver Code ; Function calling
function getCount ( A , B2 , C ) { let count = 0 ; for ( let i = 1 ; i <= A ; i ++ ) { let j = parseInt ( B2 / i ) + 1 ; if ( C >= j ) count = ( count + C - j + 1 ) ; if ( A >= j && C >= i ) count = ( count + ( C - i + 1 ) * ( A - j + 1 ) ) ; if ( A >= j ) A = j - 1 ; } return count ; } function countTriplets ( A , B , ) { let ans = 0 ; for ( let i = 1 ; i <= B ; i ++ ) { ans = ( ans + getCount ( A , i * i , C ) ) ; } return ans ; } let A , B , C ; A = 3 , B = 2 , C = 2 ; document . write ( countTriplets ( A , B , C ) ) ;