Problem: You are given natural numbers a and b. Find a^b-b^a.
Solution: It is easy to solve in C++. More easier in Java!
import java.util.Scanner;
import java.math.BigInteger;
import java.io.*;
public class Solution {
static Scanner cin = new Scanner(System.in);
public static void main(String[] args) {
BigInteger a,b,c,d,e;
Integer aa,bb;
while (cin.hasNextInt()) {
aa = cin.nextInt();
bb = cin.nextInt();
a = BigInteger.valueOf(aa);
b = BigInteger.valueOf(bb);
c = a.pow(bb);
d = b.pow(aa);
e = c.subtract(d);
System.out.println(e.toString());
}
}
}