标签:blog io ar sp java div on log bs
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); } }
快速切题 sgu 112. a^b-b^a 大数 次方 难度:0 非java:1
标签:blog io ar sp java div on log bs
原文地址:http://www.cnblogs.com/xuesu/p/4106946.html