Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- double myPow(double x, int n) {
- double res = 1.0;
- while(n){
- if(n&1) {
- if(n > 0)
- res = res*x;
- else
- res /= x;
- }
- x = x*x;
- n /= 2;
- }
- return res;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement