SGU 112 – Java BigInteger

/* Water problem...but I don't have a Java compiler in my office.
 * Several compilation error...so sad...worked in notepad.
 */
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Solution
{
	public static void main (String[] argv) throws IOException
	{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(in.readLine());
		String str = st.nextToken();
		int a = Integer.parseInt(str);
		BigInteger A = new BigInteger(str);
 
		str = st.nextToken();
		int b = Integer.parseInt(str);
		BigInteger B = new BigInteger(str);
 
		System.out.println(A.pow(b).subtract(B.pow(a)));
	}
}

Leave a Reply

Your email address will not be published.