@agnelvishal hi here is a little optimization…use squaring for last ans calculation…where u had calculated value of a…then use squaring method to reduce little complexity and try other …
Sorry but I did not understand what is squaring and where did you ask to use it.
long long int (long long int N,long long int POW)
if(POW<=0) return 1;
if(N==1) return 1;
long long int ans=1;