human
Count of pairs ( A , B ) in range 1 to N such that last digit of A is equal to the first digit of B | Function to Count of pairs ( A , B ) in range 1 to N.
count C i , j.
Calculate number of pairs.
Driver code.
Function call"
Solution in Python:
assistant
#Here is code to count of pairs ( A , B ) in range 1 to N such that last digit of A is equal to the first digit of B and the other steps required.
 def pairs ( n ) :
	c = [ [ 0 for i in range ( 10 ) ] for i in range ( 10 ) ]
	tmp = 1
	for i in range ( 1 , n + 1 ) :
		if ( i >= tmp * 10 ) :
			tmp *= 10
		c [ i // tmp ] [ i % 10 ] += 1
	ans = 0
	for i in range ( 1 , 10 ) :
		for j in range ( 1 , 10 ) :
			ans += c [ i ] [ j ] * c [ j ] [ i ]
	return ans
if __name__ == ' _ _ main _ _ ' :
	n = 25
	print ( pairs ( n ) )