close

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2683

 

#include<cstdio>

int main()
{
    int a[20] = {0}, cas = 1, n;

    a[0] = 1, a[1] = 2;
    for (int i = 2; i<20; i++)
        a[i] = a[i-1]*2;

    while (scanf("%d", &n) && n >= 0){
        for (int i = 0; i<20; i++){
            if (n <= a[i]){
                printf("Case %d: %d\n", cas, i);
                break;
            }
        }
        cas++;
    }
}

arrow
arrow
    全站熱搜

    楓綺 發表在 痞客邦 留言(0) 人氣()