[题目链接]
https://www.lydsy.com/JudgeOnline/problem.php?id=1192
[算法]
显然 , 答案为所有<=m的2的幂次
时间复杂度 : O(logN)
[代码]
#include<bits/stdc++.h> using namespace std; template <typename T> inline void chkmax(T &x,T y) { x = max(x,y); } template <typename T> inline void chkmin(T &x,T y) { x = min(x,y); } template <typename T> inline void read(T &x) { T f = 1; x = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -f; for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0'; x *= f; } int main() { int x , res = 0; read(x); while (x > 0) res++ , x >>= 1; printf("%d ",res); return 0; }