From 797ed4ec644deda5e0f6e93586b83147033dbac7 Mon Sep 17 00:00:00 2001 From: hg398 Date: Fri, 26 Oct 2018 14:14:02 -0700 Subject: [PATCH] Issue #2 A C++ program to calculate a power b. --- a^b/mod_poer.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 a^b/mod_poer.h diff --git a/a^b/mod_poer.h b/a^b/mod_poer.h new file mode 100644 index 0000000..576516a --- /dev/null +++ b/a^b/mod_poer.h @@ -0,0 +1,35 @@ + +// BY hg398 + +#include +using namespace std; +#define ll long long int +#define boost ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL) +#define FOR(i,a,b) for(int i=a;i<=b;i++) +#define mo 1000000007 + +ll mod_poer(ll a,ll b) +{ + ll res=1; + while(b>0) + { + if(b&1) + res=(res*a)%mo; + a=(a*a)%mo; + b/=2; + } + return res%mo; +} + +int main() { + boost; + int t; + cin>>t; + while(t--) + { + ll a,b; + cin>>a>>b; + cout<