#include <iostream>
using namespace std;

template<class T, class Int>
T Pow(T x, Int n)
{
    T r(1);    // 应是含幺半群的幺元
    while (n != 0)
    {
        if (n & 0x1 == 1)
        {
            r *= x;
        }
        n >>= 1;
        x *= x;
    }

    return r;
}

template <class T, class Int>
T PowBoost(T x, Int n)
{
    T r(n & 0x1 ? x : 1);
    while ((n >>= 1) != 0)
    {
        x *= x;
        if (n & 0x1 == 1)
        {
            r *= x;
        }
    }
    return r;
}

int main(int argc, char **argv)
{
    return 0;
}

 

相关文章:

  • 2022-02-17
  • 2021-12-04
  • 2021-08-14
  • 2021-06-12
  • 2021-04-04
  • 2021-06-22
  • 2021-09-28
  • 2022-12-23
猜你喜欢
  • 2021-11-16
  • 2021-06-20
  • 2021-09-09
  • 2021-11-21
  • 2021-08-25
相关资源
相似解决方案