10523 Very Easy !!!

Problem Link

Yeah,it is very easy 😉 !!

 

#Solution

 

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

public class Main {

public static void main(String[] args) {
int n,a;
Scanner sc=new Scanner(System.in);
while(sc.hasNextInt())
{
n=sc.nextInt();
a=sc.nextInt();
BigInteger res=new BigInteger(“0”);
BigInteger aA = BigInteger.valueOf(a);
for(int i=1;i<=n;i++)
{
res=res.add(BigInteger.valueOf(i).multiply(aA.pow(i)));
}
System.out.println(res);
}
}

}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized, uva and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s