面对刚开始没有头绪的题目, 先进行尝试往往是非常有必要的,
#include <cstdio> #include <iostream> using namespace std; unsigned int cal(unsigned int n){ if (n == 1) return 0; else if (n == 2) return 1; else return cal((unsigned int)(n/2))+1; } int main(){ unsigned int n; cin >> n; cout << cal(n); return 0; }