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
def getCount ( A , B2 , C ) : NEW_LINE INDENT count = 0 NEW_LINE i = 1 NEW_LINE while ( i < A ) : NEW_LINE INDENT j = ( B2 // i ) + 1 NEW_LINE if ( C >= j ) : NEW_LINE INDENT count = count + C - j + 1 NEW_LINE DEDENT if ( A >= j and C >= i ) : NEW_LINE INDENT count = count + ( C - i + 1 ) * ( A - j + 1 ) NEW_LINE DEDENT if ( A >= j ) : NEW_LINE INDENT A = j - 1 NEW_LINE DEDENT i += 1 NEW_LINE DEDENT return count NEW_LINE DEDENT def countTriplets ( A , B , C ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in range ( 1 , B + 1 ) : NEW_LINE INDENT ans = ( ans + getCount ( A , i * i , C ) ) NEW_LINE DEDENT return ans NEW_LINE DEDENT A = 3 NEW_LINE B = 2 NEW_LINE C = 2 NEW_LINE print ( countTriplets ( A , B , C ) ) NEW_LINE