Hello World!(UVA - 11636)

版权声明:若有转载,请标注原博客地址!谢谢 https://blog.csdn.net/DreamTrue1101/article/details/83750504

题目链接:Hello World! UVA - 11636 

解题思路:打表二分查询hello world最小复制次数。

代码如下:

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    int n,m,t=1;
    int data[]= {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384};
    while(~scanf("%d",&n))
    {
        if(n<0)break;
        m=0;
        while(data[m]<n)
            m++;
        printf("Case %d: %d\n",t++,m);
    }
    return 0;
}
 

猜你喜欢

转载自blog.csdn.net/DreamTrue1101/article/details/83750504