Skip to content

Instantly share code, notes, and snippets.

@abdalimran
Created February 12, 2016 19:01
Show Gist options
  • Save abdalimran/7f312c497f3564bcb9b6 to your computer and use it in GitHub Desktop.
Save abdalimran/7f312c497f3564bcb9b6 to your computer and use it in GitHub Desktop.
/* Bismillah hir rahmanir raheem. Thanks to Allah for everything.
Coder: Abdullah Al Imran
Email: [email protected] */
#include<bits/stdc++.h>
using namespace std;
//3. Using Fermat’s Little Theorem
int pow(int a, int b, int MOD)
{
int x=1, y=a;
while(b>0)
{
if(b%2==1)
{
x=(x*y);
if(x>MOD)
x%=MOD;
}
y=(y*y);
if(y>MOD)
y%=MOD;
b/=2;
}
return x;
}
int modInverse(int a, int m)
{
return pow(a,m-2,m);
}
int main()
{
ios_base::sync_with_stdio(false);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment