P21835 [GeeksforGeeks] Smallest power of 2 greater than or equal to n2630
普及-
题目描述

Given a number N.Find the nearest number which is a power of 2 and greater than or equal to N.
Example 1:
Input:
N = 1
Output:
1
Explanation:
The nearest power of 2 greater than or
equal to 1 is 2^0=1.
Example 2:
Input:
N = 5
Output:
8
Explanation:
The nearest power of 2 greater than 5 is
2^3=8.
Your Task:
You don't need to read input or print anything.Your Task is to complete the function nearestPowerOf2() which takes a number N as input parameter and returns the nearest power of 2 that is greater than or equal to N.
Expected Time Complexity:O(LogN)
Expected Auxillary Space:O(1)
Constraints:
1<=N<=10^{18}

输入格式

见题面

输出格式

见题面

样例输入
N = 1
样例输出
1