JAVA大数....
a^b-b^a
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); } } }
SGU 112 a^b-b^a,布布扣,bubuko.com
时间: 2024-10-16 18:09:36