Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- int m,pot,resultado;
- long long b,p;
- while(cin>>b){
- cin>>p>>m;
- pot=b%m;
- resultado=1;
- for(p;p>0;p/=2){
- if(p%2==1){
- resultado=(resultado*pot)%m;
- p--;
- }
- pot=(pot*pot)%m;
- }
- cout<< resultado <<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement