fork download
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int a,b,m;
  6. while(cin>>a>>b>>m)
  7. {
  8. int r=1;
  9. while(b)
  10. {
  11. if(b & 1)
  12. r=(r%m * r%m) %m;
  13. a=(a%m * a%m)%m;
  14. b/=2;
  15. }
  16. cout<<r<<endl;
  17. }
  18. return 0;
  19. }
Success #stdin #stdout 0s 3412KB
stdin
stdout
Standard output is empty