rev='made'/> name='keywords'/> name='author'/> ANURANAN: UVa Problem Solution 10523 - Very Easy !!!

Welcome Note

Hi,
I'm Anisuzzaman Babla . I am a full stack Android Application Developer. I am working with Android for more than two years. I have completed my graduation from IIT, Jahangirnagar University. I have developed a series of commercially successful apps on Android. Moreover, 10+ of my Apps are live at Google play store. .
Thank You

UVa Problem Solution 10523 - Very Easy !!!

import java.math.BigInteger;
import java.util.Scanner;

/**
 *
 * @author Babla
 */
public class Main {

        public static void main(String[] args) {      

        Scanner cin = new Scanner(System.in);
        int N, A;
        while(cin.hasNextInt()) {
            N = cin.nextInt();
            A = cin.nextInt();
            BigInteger sum = new BigInteger("0"),
                                tmpA = BigInteger.valueOf(A);
            for(int i = 1; i <= N; i++)
                sum = sum.add(BigInteger.valueOf(i).multiply(tmpA.pow(i)));
            System.out.println(sum);
        }
        }
    }


   

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Whats wrong if I declare-

    BigInteger tmpA = BigInteger.valueOf(A);// in seperate line??

    ReplyDelete