• 高速求幂 POW优化


    版权声明:本文为博主原创文章,未经博主同意不得转载。 https://blog.csdn.net/u013497151/article/details/27633731
    #include <iostream>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    using namespace std;
    
    
    int pow(int x, int n)
    {
        int result = 1;
        while (n > 0)
        {
            if (n % 2==1)      
                result *= x;
            x *= x;
            n /=2 ;    
        }
        return result;
    }
    
    
    int main()
    {
        int n,m;
        while(~scanf("%d%d",&n,&m))
           {
               int s = pow(n,m);
               printf("%d
    ",s);
           }
        return 0;
    }


  • 相关阅读:
    MySQL隐式类型转换导致索引失效
    解决MySQL报错[Err] 1093
    二:C#对象、集合、DataTable与Json内容互转示例;
    一:Newtonsoft.Json 支持序列化与反序列化的.net 对象类型;
    Newtonsoft.Json 概述
    为什么Elasticsearch查询变得这么慢了?
    Elasticsearch 5.x 字段折叠的使用
    Elasticsearch 删除数据
    Linux环境下安装 ElasticHD
    ElasticHD Windows环境下安装
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10494326.html
  • Copyright © 2020-2023  润新知