Skip to content

Commit

Permalink
Merge pull request #54 from Ayushivam22/day10
Browse files Browse the repository at this point in the history
feat: easy day 10 solution
  • Loading branch information
opabhijeet authored Apr 9, 2024
2 parents 0da133b + 001cd79 commit f7329d7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
26 changes: 26 additions & 0 deletions Easy/Day10/Solution.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
// 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 a, b, m;
cin >> a >> b >> m;

cout << BinExpo(a, b, m) << endl;
}
Binary file added Easy/Day10/Solution.exe
Binary file not shown.
31 changes: 1 addition & 30 deletions Easy/Day8/Solution.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1 @@
#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;
}
}
// Write your code here

0 comments on commit f7329d7

Please sign in to comment.