Skip to content

Commit

Permalink
feat: day8 easy solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayushivam22 committed Apr 7, 2024
1 parent 00ba639 commit b53c9a5
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion Easy/Day8/Solution.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
// Write your code here
#include <bits/stdc++.h>
using namespace std;
long long BinExpo(long long a, long long b, long long m)
{
// basse case
if (b == 0)
return 1;
// recursive case
long long res = BinExpo(a, b / 2, m);
if (b & 1) // if b is odd
{
return ((a * (res % m)) % m * (res % m)) % m;
}
else
{
return (res * res) % m;
}
}
int main()
{
long long m = 1e9 + 7;
int t;
cin >> t;
while (t--)
{
long long a, b;
cin >> a >> b;
cout << BinExpo(a, b, m) << endl;
}
}

0 comments on commit b53c9a5

Please sign in to comment.