UVA 11636 Hello World! 水题

题目链接:UVA - 11636

题意:我们要求输出n遍"Hello World!",在运用粘贴技术下,求出最少的粘贴次数。

算法分析:水题一枚,作为我正式结缘UVA的纪念吧。粘贴即把原来的输出内容复制一次,剩下的没啥好说的了。

 1 #include<iostream>

 2 #include<cstdio>

 3 #include<cstring>

 4 #include<cstdlib>

 5 #include<cmath>

 6 #include<algorithm>

 7 #define inf 0x7fffffff

 8 using namespace std;

 9 

10 int n;

11 

12 int main()

13 {

14     int ncase=1;

15     while (scanf("%d",&n)!=EOF && n>0)

16     {

17         int ans=1,cnt=0;

18         while (ans<n)

19         {

20             cnt ++ ;

21             ans *= 2;

22         }

23         printf("Case %d: %d\n",ncase++,cnt);

24     }

25     return 0;

26 }

 

你可能感兴趣的:(Hello world)