1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import java.util.Scanner; /** * UVA10268 */ public class UVA10268 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextLine()) { int x = Integer.parseInt(sc.nextLine()); String[] str = sc.nextLine().split(" "); int[] intArray = new int[str.length]; int sum = 0; for (int i = 0; i < intArray.length; i++) intArray[i] = Integer.parseInt(str[i]); for (int i = 0; i < intArray.length - 1; i++) sum += intArray[i] * (intArray.length - 1 - i) * Math.pow(x, intArray.length - 2 - i); System.out.println(sum); } sc.close(); } } |