uva 11384 - Help is needed for Dexter

代码:

 1 #include<cstdio>
 2 using namespace std;
 3 
 4 int getans(int x)
 5 {
 6     int ans=1;
 7     while(x>1)
 8     {
 9         x>>=1;
10         ans++;
11     }
12     return ans;
13 }
14 
15 int main()
16 {
17     int n;
18     while(scanf("%d",&n)!=EOF)
19         printf("%d\n",getans(n));
20     return 0;
21 }
View Code

 

posted @ 2013-10-26 10:31  Yours1103  阅读(100)  评论(0编辑  收藏  举报