(数组应用二:高精度运算4.2.2)UVA 10523 VERY EASY !!! (大数累加)

来源:互联网 发布:域名防红接口 编辑:程序博客网 时间:2024/06/08 07:26
package com.njupt.acm;import java.math.BigInteger;import java.util.Scanner;public class UVA_10523 {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);while(scanner.hasNext()){int n = scanner.nextInt();int a = scanner.nextInt();int i;BigInteger sum = new BigInteger("0");for(i = 1 ; i <= n ; ++i){sum = sum.add(new BigInteger(i +"").multiply(new BigInteger(a+"").pow(i)));}System.out.println(sum);}}}

原创粉丝点击