UVA10523:

Very Easy !!!

import java.util.*;
import java.math.*;


public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int N = sc.nextInt();
			int A = sc.nextInt();
			BigInteger sum = new BigInteger("0");
			BigInteger tempA = BigInteger.valueOf(A);
			for(int i = 1; i <= N; i++){
				sum = sum.add(BigInteger.valueOf(i).multiply(tempA.pow(i)));
			}

			System.out.println(sum);
		}

	}

}
[Back to Listing Page]

Home

Posts

Projects

Github

Contact

janzzen

Developed by Janzzen Ang powered by Vercel