import java.util.Scanner;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (input.hasNext()) {
int n = input.nextInt();
int a = input.nextInt();
BigInteger A = BigInteger.valueOf(a);
BigInteger sum = BigInteger.ZERO;
for (int i = 1; i <= n; i++) {
sum = sum.add(BigInteger.valueOf(i).multiply(A.pow(i)));
}
System.out.println(sum);
}
}
}
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (input.hasNext()) {
int n = input.nextInt();
int a = input.nextInt();
BigInteger A = BigInteger.valueOf(a);
BigInteger sum = BigInteger.ZERO;
for (int i = 1; i <= n; i++) {
sum = sum.add(BigInteger.valueOf(i).multiply(A.pow(i)));
}
System.out.println(sum);
}
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন