Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- long long int bigmod(long long int a,long long int b,long long int m)
- {
- if(b==0)
- return 1;
- long long int x=bigmod(a,b/2,m);
- x=(x*x)%m;
- if(b%2==1)
- x=(x*a)%m;
- return x;
- }
- int main()
- {
- long long int a,b,m;
- while(scanf("%lld",&a)!=EOF)
- {
- scanf("%lld %lld",&b,&m);
- long long int ans=bigmod(a,b,m);
- printf("%lld\n",ans);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement