首页 > 其他 > 详细

SGU 112 a^b-b^a

时间:2014-06-30 19:36:03      阅读:371      评论:0      收藏:0      [点我收藏+]


JAVA大数....


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

[]   [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

[]   [Go Back]   [Status]  

bubuko.com,布布扣



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

SGU 112 a^b-b^a

原文:http://blog.csdn.net/ck_boss/article/details/35853135

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!