fork download
  1. class Main{
  2. public static long pow(long a, long b){
  3. if(b == 0){
  4. return 1;
  5. }
  6. if(b % 2 == 0){
  7. return pow(a * a, b / 2);
  8. }
  9. return a * pow(a, b - 1);
  10. }
  11. public static void main (String[] args){
  12. java.util.Scanner in = new java.util.Scanner(System.in);
  13. long a = in.nextLong(), b = in.nextLong();
  14. System.out.println(pow(a,b));
  15. }
  16. }
Success #stdin #stdout 0.1s 35596KB
stdin
2 5
stdout
32