码迷,mamicode.com
首页 > 其他好文 > 详细

SGU 112 a^b-b^a

时间:2014-06-30 19:35:34      阅读:296      评论:0      收藏:0      [点我收藏+]

标签:des   style   http   java   color   strong   


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

标签:des   style   http   java   color   strong   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!