UVa 11384 Help is needed for Dexter——思路题

来源:互联网 发布:网络数据库类型有哪些 编辑:程序博客网 时间:2024/06/02 05:31

f(n) = f( n  / 2) + 1

可以借助uDebug的数据来辅助思考

#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;int solve(int n) {    if (n == 1) return 1;    return solve(n / 2) + 1;}int main(){    int n;    while (scanf("%d", &n) == 1) {        printf("%d\n", solve(n));    }    return 0;}