快速切题 sgu 112. a^b-b^a 大数 次方 难度:0 非java:1

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);
	}
}

  

posted @ 2014-11-18 22:32  雪溯  阅读(197)  评论(0编辑  收藏  举报