import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n1 = scanner.nextInt(); int num = n1; int n2 = scanner.nextInt(); long result = 0; //2 + 2*1 //2 //2*10 20+2 = 22 //2*100=200 200+22; if (n2 >= 1) { result = n1; } for (int i = 1; i < n2; i++) { n1 = (int) (n1 + num * Math.pow(10, i)); result += n1; } System.out.println(result); } } |
Double click to view unformatted code.