import java.util.Scanner; /** * @Author Tianyiya H.T.W * @Date 2019/1/8 11:23 */ public class Main { private static int pow(int x, int n) { int base = x; int result = 1; while (n > 0) { if ((n & 1) == 1) { result *= base; } base *= base; n >>= 1; } return result; } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int x = scanner.nextInt(); int n = scanner.nextInt(); System.out.println(pow(x, n)); } } }
快速冪
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.