Function to count number of sub - arrays whose sum is k ^ p where p >= 0
def countSubarrays ( arr , n , k ) : NEW_LINE INDENT prefix_sum = [ 0 ] * MAX NEW_LINE prefix_sum [ 0 ] = 0 NEW_LINE prefix_sum = partial_sum ( prefix_sum , arr , n ) NEW_LINE if ( k == 1 ) : NEW_LINE INDENT sum = 0 NEW_LINE m = defaultdict ( int ) NEW_LINE for i in range ( n , - 1 , - 1 ) : NEW_LINE DEDENT DEDENT