傻做就O(n), 要更好就考虑O(logN). 1. If n == even: return val * val 2. If n != even: return val * val * x; Also, consider the sign of x.