JAVA大数....
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 |
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);
}
}
}