SGU 112 a^b-b^a

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

SGU 112 a^b-b^a,布布扣,bubuko.com

时间: 2024-10-16 18:09:36

SGU 112 a^b-b^a的相关文章

快速切题 sgu 112. a^b-b^a 大数 次方 难度:0 非java:1

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 3Sample Output -1 import j

a^b-b^a - SGU 112(高精度快速幂)

分析:直接上吧,建议不要使用模板,否则没啥意义了. 代码如下: =================================================================================================================================== #include<algorithm> #include<stdio.h> #include<string.h> #include<queu

SGU 438 The Glorious Karlutka River =) 拆点+动态流+最大流

The Glorious Karlutka River =) Time Limit:500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice SGU 438 Appoint description: Description A group of Mtourists are walking along the Karlutka river. They want to cross

sgu Kalevich Strikes Back

这道题就是求一个大矩形被n个矩形划分成n+1个部分的面积,这些矩形之间不会相交,可能包含.. 1 #include <cstdio> 2 #include <cstring> 3 #include <vector> 4 #include <algorithm> 5 #define maxn 120100 6 using namespace std; 7 8 long long s[maxn]; 9 vector<int>g[maxn]; 10 i

数学计数原理(P&#243;lya,高精度):SGU 294 He&#39;s Circles

He's Circles He wrote n letters "X" and "E" in a circle. He thought that there were 2n possibilities to do it, because each letter may be either "X" or "E". But Qc noticed that some different sequences of letters ca

sgu Ice-cream Tycoon

题意:供应商提供n块价格为c的冰淇淋,一个学生想买n块冰淇淋,手中的钱数总共有t元,为了不让买n块冰淇淋所花费的钱数不超过t元,先尽可能卖给这个学生便宜的冰淇淋. 如果这个学生不能买到所需要的冰淇淋则输出“UNHAPPY”,能则输出“HAPPY”. 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #define maxn 200000 5 using namespace std; 6 7

sgu 463 - Walking around Berhattan

K - Walking around Berhattan Time Limit:250MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice SGU 463 Description As you probably know, Berhattan is a district of Berland's largest city and it consists of equal squar

【SGU 390】Tickets (数位DP)

Tickets Description Conductor is quite a boring profession, as all you have to do is just to sell tickets to the passengers. So no wonder that once upon a time in a faraway galaxy one conductor decided to diversify this occupation. Now this conductor

ACM: SGU 101 Domino- 欧拉回路-并查集

sgu 101 - Domino Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Description Dominoes – game played with small, rectangular blocks of wood or other material, each identified by a number of dots, or pips, on its face. The bl