zoukankan      html  css  js  c++  java
  • UVa 11636 Hello World! (水题思维)

    题意:给你一个数,让你求需要复制粘贴多少次才能达到这个数。

    析:这真是一个水题,相当水,很容易知道每次都翻倍,只要大于等于给定的数就ok了。

    代码如下:

    #include <iostream>
    #include <cstdio>
    #include <cmath>
    
    using namespace std;
    
    
    int main(){
        int n, kase = 0;
        while(scanf("%d", &n) && n >= 0){
            printf("Case %d: ", ++kase);
            for(int i = 0; ; ++i)
                if(n - (1<<i) <= 0){  printf("%d
    ", i);  break; }
    
        }
        return 0;
    }
    
    #include <iostream>
    #include <cstdio>
    #include <cmath>
    
    using namespace std;
    
    
    int main(){
        int n, kase = 0;
        while(scanf("%d", &n) && n >= 0){
            int ans = (int)ceil(log2(n)) == (int)log2(n) ? (int)log2(n) : (int)log2(n) + 1;
            printf("Case %d: %d
    ", ++kase, ans);
        }
        return 0;
    }
    
  • 相关阅读:
    Red and Black POJ
    Catch That Cow HDU
    Lotus and Horticulture HDU
    进击的绿色
    北京办护照
    女码农真诚征gg
    bitset
    long long
    cnblogs latex公式
    2050 Programming Competition (CCPC)
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/5533030.html
Copyright © 2011-2022 走看看