UVA 10268 Java

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

留言

這個網誌中的熱門文章

C# 井字遊戲