首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

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

2013-10-28 
(数组应用二:高精度运算4.2.2)UVA 10523VERY EASY !!! (大数累加)package com.njupt.acmimport java.math

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

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);}}}

热点排行