设为首页 加入收藏

TOP

SGU 112 a^b-b^a
2015-07-24 05:49:08 来源: 作者: 【 】 浏览:4
Tags:SGU 112 b-b


JAVA大数....


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

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

[Submit] [Go Back] [Status]

\



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



】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇UVA 11490 - Just Another Proble.. 下一篇C++生成简单WAV文件(二)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: