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


查看全文
  • 相关阅读:
    WPF 本地化语言设置
    WPF 调节树状图滚动条值
    WPF中ListBox的使用注意事项
    SQL 树状结构表中查出所所有父级/子级
    Vue创建
    wpf 控件注意事项
    链表习题(1)-设计一个递归算法,删除不带头结点的单链表L中所有值为x的结点
    排序-快速排序
    排序-堆排序
    图-图的遍历
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10494326.html
  • Copyright © 2011-2022 走看看