标签:
1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 #include <vector> 5 #include <cstring> 6 #include <string> 7 #include <algorithm> 8 #include <string> 9 #include <set> 10 #include <functional> 11 #include <numeric> 12 #include <sstream> 13 #include <stack> 14 #include <map> 15 #include <queue> 16 #pragma comment(linker, "/STACK:102400000,102400000") 17 #define CL(arr, val) memset(arr, val, sizeof(arr)) 18 19 #define ll long long 20 #define inf 0x7f7f7f7f 21 #define lc l,m,rt<<1 22 #define rc m + 1,r,rt<<1|1 23 #define pi acos(-1.0) 24 25 #define L(x) (x) << 1 26 #define R(x) (x) << 1 | 1 27 #define MID(l, r) (l + r) >> 1 28 #define Min(x, y) (x) < (y) ? (x) : (y) 29 #define Max(x, y) (x) < (y) ? (y) : (x) 30 #define lson l,m,rt<<1 31 #define rson m+1,r,rt<<1|1 32 #define E(x) (1 << (x)) 33 #define iabs(x) (x) < 0 ? -(x) : (x) 34 #define OUT(x) printf("%I64d\n", x) 35 #define lowbit(x) (x)&(-x) 36 #define Read() freopen("a.txt", "r", stdin) 37 #define Write() freopen("b.txt", "w", stdout); 38 #define maxn 100010 39 #define mod 1000000007 40 using namespace std; 41 42 ll quick_mod(ll a,ll b,ll c) 43 { 44 ll ans=1; 45 while(b) 46 { 47 if(b&1) 48 { 49 ans=(ans*a)%c; 50 b--; 51 } 52 b/=2; 53 a=(a*a)%c; 54 } 55 return ans; 56 } 57 int main() 58 { 59 // freopen("a.txt","r",stdin); 60 ll a,b,c; 61 scanf("%lld%lld%lld",&a,&b,&c); 62 printf("%lld\n",quick_mod(a,b,c)); 63 return 0; 64 }
标签:
原文地址:http://www.cnblogs.com/nowandforever/p/4581900.html