UVA 11384 - Help is needed for Dexter

题目地址: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2379


递推类型题目。


代码如下:

#include <iostream>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
using namespace std;


const int N=1510;
typedef long long LL;

int f(int k)
{
    if(k==1)
        return 1;
    return f(k/2)+1;
}

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",f(n));
    }
    return 0;
}


你可能感兴趣的:(UVA 11384 - Help is needed for Dexter)