// UVa 10523 - Very Easy !!! import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNextInt()) { int n = scanner.nextInt(); BigInteger a = scanner.nextBigInteger(); BigInteger sol = BigInteger.ZERO; BigInteger power = BigInteger.ONE; for (int i = 1; i <= n; i++) { power = power.multiply(a); sol = sol.add(power.multiply(BigInteger.valueOf(i))); } System.out.println(sol); } } }
Showing posts with label UVa 10523 - Very Easy !!!. Show all posts
Showing posts with label UVa 10523 - Very Easy !!!. Show all posts
Friday, August 14, 2015
UVa 10523 - Very Easy !!!
Subscribe to:
Posts (Atom)