zoukankan      html  css  js  c++  java
  • [HNOI 2006] 鬼谷子的钱袋

    [题目链接]

              https://www.lydsy.com/JudgeOnline/problem.php?id=1192

    [算法] 

             显然 , 答案为所有<=m的2的幂次

             时间复杂度 : O(logN)

    [代码]

            

    #include<bits/stdc++.h>
    using namespace std;
    
    template <typename T> inline void chkmax(T &x,T y) { x = max(x,y); }
    template <typename T> inline void chkmin(T &x,T y) { x = min(x,y); }
    template <typename T> inline void read(T &x)
    {
        T f = 1; x = 0;
        char c = getchar();
        for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
        for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
        x *= f;
    }
    int main()
    {
            
            int x , res = 0;
            read(x);
            while (x > 0) res++ , x >>= 1;
            printf("%d
    ",res);
            
            return 0;
        
    }
  • 相关阅读:
    3-8
    3-7
    3-5
    3-4
    3-3
    3-2
    3-1
    2-11
    2-10
    2-9
  • 原文地址:https://www.cnblogs.com/evenbao/p/9823319.html
Copyright © 2011-2022 走看看