找出N是2的幾次方,並取其次方上界之整數即可得解。
C++(0.015)
/*******************************************************/
/* UVa 11636 Hello World! */
/* Author: Maplewing [at] knightzone.studio */
/* Version: 2015/03/15 */
/*******************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
int caseNumber = 1;
int N;
while( scanf("%d", &N) != EOF && N > 0 ){
int Y = ceil(log2(N));
printf("Case %d: %d\n", caseNumber++, Y);
}
return 0;
}