Created
November 28, 2016 09:55
-
-
Save HyeonWooKim/4192dbcbb5df2cddad0f3c103fdc684d to your computer and use it in GitHub Desktop.
BOJ 1629
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<vector> | |
#include<algorithm> | |
using namespace std; | |
int main() | |
{ | |
long long b,e,m,o=1; | |
cin>>b>>e>>m; | |
b%=m; | |
while(e) | |
{ | |
if(e%2==1) | |
o=(o*b)%m,e--; | |
else | |
b=(b*b)%m,e/=2; | |
} | |
cout<<o; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment