112. a^b-b^a
time limit per test: 0.25 sec.
memory limit per test: 4096 KB
You are given natural numbers a and b. Find a^b-b^a.
Input
Input contains numbers a and b (1≤a,b≤100).
Output
Write answer to output.
Sample Input
2 3
Sample Output
-1
import java.io.*; import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String []args) throws IOException{ int a,b; Scanner scanner=new Scanner(System.in); a=scanner.nextInt();b=scanner.nextInt(); BigInteger A=BigInteger.valueOf(a); BigInteger B=BigInteger.valueOf(b); A=A.pow(b);B=B.pow(a); A=A.subtract(B); System.out.println(A); } }