Function to count number of sub - arrays whose sum is k ^ p where p >= 0
static int countSubarrays ( int [ ] arr , int n , int k ) { long [ ] prefix_sum = new long [ MAX ] ; prefix_sum [ 0 ] = 0 ; prefix_sum = partial_sum ( prefix_sum , arr , n ) ; int sum ; if ( k == 1 ) { sum = 0 ; Dictionary < long , int > mp = new Dictionary < long , int > ( ) ; for ( int i = n ; i >= 0 ; i -- ) {