fork download
  1. #include <stdio.h>
  2. #include <algorithm>
  3.  
  4. int A, B, C;
  5. long long pow(int b) {
  6. if (b == 1) return A % C;
  7. long long ans = pow(b >> 1) * pow(b >> 1);
  8. ans %= C;
  9. if (b % 2 == 1) {
  10. ans *= A; ans %= C;
  11. }
  12. return ans;
  13. }
  14.  
  15. int main() {
  16. scanf("%d %d %d", &A, &B, &C);
  17. printf("%lld\n", pow(B));
  18. return 0;
  19. }
  20.  
  21.  
  22.  
Success #stdin #stdout 0s 4260KB
stdin
1 1000000000 1
stdout
0