binary exponentiation
C++
#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;
}
Also in C++:
- Title
- get data from terminal c++
- Category
- C++
- Title
- c++ char if
- Category
- C++
- Title
- prefix sum array
- Category
- C++
- Title
- error: ISO C++ forbids comparison between pointer and integer [-fpermissive] if(s[i] != "b"){
- Category
- C++
- Title
- filling 2d array with 0 c++
- Category
- C++
- Title
- how to include seld declared header file in c++
- Category
- C++
- Title
- program to know if a number is prime
- Category
- C++
- Title
- range of int
- Category
- C++
- Title
- c++ string to stream
- Category
- C++
- Title
- counting valleys hackerrank solution in c++
- Category
- C++
- Title
- getting a random letter in c++
- Category
- C++
- Title
- C++ Student::Student()
- Category
- C++
- Title
- rosrun actionlib_msgs genaction.py
- Category
- C++
- Title
- c++ cli convert string to string^
- Category
- C++
- Title
- how to have a queue as a parameter in c++
- Category
- C++
- Title
- c++ char define
- Category
- C++
- Title
- opencv compile c++
- Category
- C++
- Title
- min coin change problem dp
- Category
- C++
- Title
- *min_element in c++
- Category
- C++
- Title
- what is difference between ciel and floor
- Category
- C++
- Title
- queue c++
- Category
- C++
- Title
- maximum subarray sum equal with K in c++
- Category
- C++
- Title
- how to delete something in an array c++
- Category
- C++
- Title
- case label in c++
- Category
- C++
- Title
- console colors in C++
- Category
- C++
- Title
- c++ throw exception
- Category
- C++
- Title
- c++ wait for user input
- Category
- C++
- Title
- print type cpp
- Category
- C++
- Title
- set c++
- Category
- C++
- Title
- c++ client service ros
- Category
- C++
- Title
- c++ class constructor
- Category
- C++
- Title
- c++ set add element
- Category
- C++
- Title
- C++ and endl
- Category
- C++
- Title
- how to convert int to string c++
- Category
- C++
- Title
- pbds in c++
- Category
- C++
- Title
- FInd the element which appears more than n/2 times C++
- Category
- C++
- Title
- c++ triple
- Category
- C++
- Title
- count function c++
- Category
- C++
- Title
- C++ remove element from set
- Category
- C++
- Title
- initialize int c++
- Category
- C++
- Title
- map vs unordered_map in C++
- Category
- C++
- Title
- can we compare a long long int with int in c++ using max or min functions
- Category
- C++
- Title
- matrix transpose tiling
- Category
- C++
- Title
- stack function in cpp
- Category
- C++
- Title
- arrow operator c++
- Category
- C++
- Title
- c++ looping through a vector
- Category
- C++
- Title
- tellg and seekg c++
- Category
- C++
- Title
- arduino falling edge
- Category
- C++
- Title
- free or delete in c++
- Category
- C++
- Title
- preorder traversal
- Category
- C++
- Title
- char* to int in cpp
- Category
- C++
- Title
- append string to another string c++
- Category
- C++
- Title
- euler phi gfg
- Category
- C++
- Title
- C++ w3schools
- Category
- C++
- Title
- fail() in c++
- Category
- C++
- Title
- how to iterate through array in c++
- Category
- C++
- Title
- c++ pi
- Category
- C++
- Title
- queue stl c++
- Category
- C++
- Title
- expected unqualified-id before 'if'
- Category
- C++
- Title
- first prime numbers less than
- Category
- C++
- Title
- restting a queue stl
- Category
- C++
- Title
- binary search stl in c++
- Category
- C++
- Title
- how to get last element of set in c++
- Category
- C++
- Title
- system("pause") note working c++
- Category
- C++
- Title
- for loop
- Category
- C++
- Title
- c++ do while loop
- Category
- C++
- Title
- graph using djacency matrix c++
- Category
- C++
- Title
- pop_back
- Category
- C++
- Title
- create copy of range of string c++
- Category
- C++
- Title
- uepic games github
- Category
- C++
- Title
- digitalwrite C++
- Category
- C++
- Title
- correct sequence of compilation process in c++
- Category
- C++
- Title
- how print fload wiht 3 decimal in c++
- Category
- C++
- Title
- fmod c++
- Category
- C++
- Title
- lisy stl C++
- Category
- C++
- Title
- delete files c++
- Category
- C++
- Title
- c++ crash windows
- Category
- C++
- Title
- vprintf
- Category
- C++
- Title
- substitution failure is not an error
- Category
- C++
- Title
- how to read and write in a file c++
- Category
- C++
- Title
- how read a shader from another file c++
- Category
- C++
- Title
- how to show c++ binary files in sublime text
- Category
- C++
- Title
- how to decalre a string in c++
- Category
- C++
- Title
- how to convert string into number
- Category
- C++
- Title
- power c++
- Category
- C++
- Title
- how to initialize a vector in c++
- Category
- C++
- Title
- can you use rand to read in from an external file inc++
- Category
- C++
- Title
- compile c++ linux
- Category
- C++
- Title
- c++ method name
- Category
- C++
- Title
- cpp how to create an object of template class
- Category
- C++
- Title
- c++ remove item from list
- Category
- C++
- Title
- vertical traversal of binary tree
- Category
- C++
- Title
- traverse a map
- Category
- C++
- Title
- set of vectors c++
- Category
- C++
- Title
- adding element in vector c++
- Category
- C++
- Title
- Shortest Distance in a Maze
- Category
- C++
- Title
- clear qlayout
- Category
- C++
- Title
- mkdir c++
- Category
- C++
- Title
- sieve of eratosthenes c++
- Category
- C++
- Title
- function template
- Category
- C++