⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uselessfile.cpp

📁 VC7.1中如果将char*作为key的话需要重载关于char*的hash_compare函数 可是我怎么都没法搞定 只好将char*转为int
💻 CPP
字号:
#define BitsOf(type) (8*sizeof(type))
typedef unsigned Int; // define your type of UNSIGNED integer.

inline int FastEstimateLeading0s(Int a)
{
    if (a) {
        int i = 0;
        for(int j = BitsOf(Int) / 2; !(a >> j); j>>=1)
            i += j;
        return i;
    }
    return BitsOf(Int);
}

inline int EvenRound(int i)
{
    return (i | 1) - 1;
}

Int isqrt(Int a)
{
    int i = FastEstimateLeading0s(a);

    a <<= i = EvenRound(i);
    Int rem = 0, root = 0;
    for(int k = (BitsOf(Int) - i) >> 1; k; --k)
    {
        root <<= 1;
        rem = (rem << 2) + ( a >> (BitsOf(Int) - 2));
        a <<= 2;
        if (root < rem)
            rem -= (++ root) ++;
    }

    return root >> 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -