首页 > 代码库 > SGU 112 a^b-b^a

SGU 112 a^b-b^a


JAVA大数....


a^b-b^a
Time Limit: 250MS Memory Limit: 4096KB 64bit IO Format: %I64d & %I64u

[Submit]   [Go Back]   [Status]  

Description

You are given natural numbers a and b. Find ab-ba.

Input

Input contains numbers a and b (1≤a,b≤100).

Output

Write answer to output.

Sample Input

2 3

Sample Output

-1

Source

[Submit]   [Go Back]   [Status]  




import java.util.*;
import java.math.*;

public class Solution
{
	public static void main(String[] args)
	{
		Scanner cin=new Scanner(System.in);
		BigInteger a,b;
		int A,B;
		while(cin.hasNextInt())
		{
			A=cin.nextInt();
			B=cin.nextInt();
			a=BigInteger.valueOf(A);
			b=BigInteger.valueOf(B);
			
			BigInteger c=BigInteger.ZERO;
			c=a.pow(B).subtract(b.pow(A));

			System.out.println(c);
		}
	}
}