快速幂运算

来源:互联网 发布:用友数据库安装步骤 编辑:程序博客网 时间:2024/05/05 17:15


#include<iostream>using namespace std;typedef long long ll;ll pow(int a,int n){    ll res=1;    while(n)    {        if(n & 1)res=res*a;        a=a*a;        n>>=1;    }    return res;}int main(){    int a,n;    while(cin>>a>>n)        cout<<pow(a,n);}


0 0