human
Count of Rectangles with area K made up of only 1 s from given Binary Arrays | Function to find the subarrays of all possible lengths made up of only 1 s.
Stores the frequency of the subarrays.
Check if the previous value was also 0.
If the previous value was 1.
Find the subarrays of each size from 1 to count.
If A [ ] is of the form ... .111.
Function to find the count of all possible rectangles.
Size of each of the arrays.
Stores the count of subarrays of each size consisting of only 1 s from array A [ ].
Stores the count of subarrays of each size consisting of only 1 s from array B [ ].
Iterating over all subarrays consisting of only 1 s in A [ ].
If i is a factor of K , then there is a subarray of size K / i in B [ ].
Driver Code"
How can the above be solved in Python?

What is a code to count of Rectangles with area K made up of only 1 s from given Binary Arrays and the other steps required?
assistant
#Here is code to count of Rectangles with area K made up of only 1 s from given Binary Arrays and the other steps required.
 def findSubarrays ( a ) :
	n = len ( a )
	freq = [ 0 ] * ( n + 1 )
	count = 0
	for i in range ( n ) :
		if ( a [ i ] == 0 ) :
			if ( count == 0 ) :
				continue
			else :
				value = count
				for j in range ( 1 , count + 1 ) :
					freq [ j ] += value
					value -= 1
				count = 0
		else :
			count += 1
	if ( count > 0 ) :
		value = count
		for j in range ( 1 , count + 1 ) :
			freq [ j ] += value
			value -= 1
	return freq
def countRectangles ( a , b , K ) :
	n = len ( a )
	m = len ( b )
	subA = [ ]
	subA = findSubarrays ( a )
	subB = [ ]
	subB = findSubarrays ( b )
	total = 0
	for i in range ( 1 , len ( subA ) ) :
		if ( K % i == 0 and ( K // i ) <= m ) :
			total = total + subA [ i ] * subB [ K // i ]
	print ( total )
a = [ 0 , 0 , 1 , 1 ]
b = [ 1 , 0 , 1 ]
K = 2
countRectangles ( a , b , K )