Title description: Title link: https://www.luogu.com.cn/problem/P1634
Code example:
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
long x = scanner.nextLong();
long n = scanner.nextLong();
long result = 1; // 结果,保证 x,n 以及答案都在 64 位无符号整数的表示范围内,所以用long
for (int i = 0; i < n; i++) {
result += result * x;
}
System.out.println(result);
}
}
Test Results: