Pabon_SEC

Very Easy !!!

Feb 17th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.70 KB | None | 0 0
  1. import java.math.BigInteger;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6.     public static void main(String[]args)
  7.     {
  8.         BigInteger sum,bi,bi1,bi2,bi3;
  9.         int i,N,A;
  10.  
  11.         Scanner sc = new Scanner(System.in);
  12.  
  13.         while(sc.hasNext())
  14.         {
  15.             N = sc.nextInt();
  16.             A = sc.nextInt();
  17.  
  18.             sum = BigInteger.ZERO;
  19.  
  20.             for( i=1 ; i<=N ; i++)
  21.             {
  22.                 bi = BigInteger.valueOf(i);
  23.  
  24.                 bi1 = BigInteger.valueOf(A);
  25.  
  26.                 bi2 = bi1.pow(i);
  27.  
  28.                 bi3 = bi2.multiply(bi);
  29.  
  30.                 sum = sum.add(bi3);
  31.  
  32.             }
  33.             System.out.println(sum);
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment