Answers for "exponenciacion binaria"

C++
2

exponenciacion binaria

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
//complexity O(log k)
ull po(ull n,ull k){
	ull x=1;
	while(k){
		if(k&1)
			x*=n;
		n*=n;
		k>>=1;
	}
	return x;
}
int main(){
	ull n,m;
    //n^m
	cin>>n>>m;
	cout<<po(n,m);
	return 0;
}
Posted by: Guest on April-30-2020

Code answers related to "exponenciacion binaria"

Browse Popular Code Answers by Language