human
Number of substrings with length divisible by the number of 1 's in it | Function return count of such substring.
Mark 1 at those indices where '1' appears.
Take prefix sum.
Iterate through all the substrings.
Driver Code"
Solution in Python:
assistant
#Here is code to number of substrings with length divisible by the number of 1 's in it and the other steps required.
 def countOfSubstrings ( s ) :
	n = len ( s )
	prefix_sum = [ 0 for i in range ( n ) ]
	for i in range ( n ) :
		if ( s [ i ] == '1' ) :
			prefix_sum [ i ] = 1
	for i in range ( 1 , n , 1 ) :
		prefix_sum [ i ] += prefix_sum [ i - 1 ]
	answer = 0
	for i in range ( n ) :
		for j in range ( i , n , 1 ) :
			if ( i - 1 >= 0 ) :
				countOfOnes = prefix_sum [ j ] - prefix_sum [ i - 1 ]
			else :
				countOfOnes = prefix_sum [ j ]
			length = j - i + 1
			if ( countOfOnes > 0 and length % countOfOnes == 0 ) :
				answer += 1
	return answer
if __name__ == ' _ _ main _ _ ' :
	S = "1111100000"
	print ( countOfSubstrings ( S ) )