zoukankan      html  css  js  c++  java
  • 高速求幂 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;
    }


查看全文
  • 相关阅读:
    一定间隔时间下重复执行一个函数的几个方法
    关于 MonoDevelop on Linux 单步调试问题的解决
    MonoDevelop 4.2.2/Mono 3.4.0 in CentOS 6.5 安装笔记
    在ASP.NET MVC 4 on Mono中使用OracleClient in CentOS 6.x的问题记录
    在CentOS 6.4 x86_32中使用Rhythmbox听MP3
    MonoDevelop 4.0.9 on CentOS 6.3 安装笔记
    MemoryMappedFile 在 Mono in Linux 的开发笔记
    Mono on CentOS 6.3 安装笔记
    庆祝下:iOS 开发者企业级计划(299美元/年帐户+邓白氏码免费) 和 Windows Phone公司应用(公司帐户99美元+Symantec企业证书299美元/年))顺利发布成功
    PowerDesigner中NAME和COMMENT的互相转换,需要执行语句
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10494326.html
  • Copyright © 2011-2022 走看看