Iterative Function to calculate base ^ pow in O ( log y )
unsigned long long power ( unsigned long long base , unsigned long long pow ) { unsigned long long res = 1 ; while ( pow > 0 ) { if ( pow & 1 ) res = ( res * base ) ; base = ( base * base ) ; pow >>= 1 ; } return res ; }