#include<bits/stdc++.h>
using namespace std;
long long m, a, b;
long long bigmod(long long b)
{
if(b==0) return 1;
else if(b%2==1) return (bigmod(b/2)*a*bigmod(b/2))%m;
else return (bigmod(b/2)*bigmod(b/2))%m;
}
int main()
{
while(scanf("%lld%lld%lld", &a,&b,&m)!=EOF) cout<<bigmod(b)<<endl;
return 0;
}
|
Friday, March 25, 2016
UVa 374-Big Mod
Subscribe to:
Post Comments (Atom)
-
#include<bits/stdc++.h> #define ll long long using namespace std ; ll n , k , t_case ; ll bigmod ( ll b , ll p , ll m...
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ...
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3...
http://mahfuziu.blogspot.com/2016/03/modulo-of-big-number.html
ReplyDelete