From 7576b60b42771903f425ca180e64e4f9c0aa32c8 Mon Sep 17 00:00:00 2001 From: Kotecha Udit Hitendra <64374551+kirito-udit@users.noreply.github.com> Date: Sat, 2 Oct 2021 20:06:04 +0530 Subject: [PATCH] Create Binary Exponentiation.cpp --- Algorithms/Binary Exponentiation.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Algorithms/Binary Exponentiation.cpp diff --git a/Algorithms/Binary Exponentiation.cpp b/Algorithms/Binary Exponentiation.cpp new file mode 100644 index 0000000..a7fd44e --- /dev/null +++ b/Algorithms/Binary Exponentiation.cpp @@ -0,0 +1,19 @@ +#include +using namespace std; +long long binpow(long long a, long long b) { + long long res = 1; + while (b > 0) { + if (b & 1) + res = res * a; + a = a * a; + b >>= 1; + } + return res; +} +int main() +{ + long long a,b; + cin >> a >> b; + cout<