UVA 10268 Java
import java.util.*; public class main{ 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(" "); //System.out.println(x); int output = 0; for(int i = 0; i < str.length - 1; i++) { int n = Integer.parseInt(str[i]); output += n * Math.pow(x, str.length -2 -i) * (str.length -1 -i); } System.out.println(output); } } };
留言
張貼留言