编程题38:
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int A = scanner.nextInt();
int N = scanner.nextInt();
BigInteger sum = BigInteger.ZERO;
BigInteger term = BigInteger.ZERO;
for (int i = 0; i < N; i++) {
term = term.multiply(BigInteger.TEN).add(BigInteger.valueOf(A));
sum = sum.add(term);
}
System.out.println(sum);
}
}
浙公网安备 33010602011771号