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;
    }


查看全文
  • 相关阅读:
    梦断代码读书笔记2
    梦断代码读书笔记1
    几篇有用的博客链接
    关于我的Androidstudio的再生
    项目下app目录的具体说明
    关于Android studio的项目界面各部分的认识
    1088 最长回文子串 分类: 51nod 2015-07-20 22:09 8人阅读 评
    1083 矩阵取数问题 分类: 51nod 2015-07-20 22:05 9人阅读 评
    1087 1 10 100 1000 分类: 51nod 2015-07-18 21:59 6人
    51nod 1091 线段的重叠 分类: 51nod 2015-07-18 21:49 7人阅读
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10494326.html
  • Copyright © 2011-2022 走看看