10523 – Very Easy !!!

C++ Code:
But it will not work as c++ don’t support BigIntger so we have to write it in java my code:

using namespace std;
int main()
    int sum=0,n,a;
    while(scanf("%d %d",&n,&a)==2)

        for(int i=1; i<=n; i++)

    return 0;


import java.math.BigInteger;
import java.util.Scanner;
import java.util.*;
import java.io.IOException;
import java.math.*;

public class Uva_Very_Easy {
    public static void main(String[] args) {
        int n, a;
        BigInteger ans, tmpA;
        Scanner input = new Scanner(System.in);

        while (input.hasNext()) {
            n = input.nextInt();
            a = input.nextInt();
            ans = new BigInteger("0");
            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)));




It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *