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


查看全文
  • 相关阅读:
    C++ 虚基类表指针字节对齐
    C++ 虚函数的内存分配
    虚函数&&虚继承
    内存管理简便复习总结
    stack,heap的区别
    内存泄漏(memory leak)和内存溢出
    php+mysqli预处理技术实现添加、修改及删除多条数据的方法
    JavaScript 常用方法总结
    6个超实用的PHP代码片段
    php 备份数据库代码(生成word,excel,json,xml,sql)
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10494326.html
  • Copyright © 2011-2022 走看看