快速切题 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 3
Sample Output

-1

import java.io.*;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String []args) throws IOException{
		int a,b;
		Scanner scanner=new Scanner(System.in);
		a=scanner.nextInt();b=scanner.nextInt();
		BigInteger A=BigInteger.valueOf(a);
		BigInteger B=BigInteger.valueOf(b);
		A=A.pow(b);B=B.pow(a);
		A=A.subtract(B);
		System.out.println(A);
	}
}

  

时间: 2024-10-06 19:44:49

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

快速切题 cf118A

这教导人们一定要看题,要看题,元音包含了‘y’,完毕,要看题啊 #include <cstring> #include <cstdio> #include <cctype> using namespace std; char buff[1001]; int main(){ scanf("%s",buff); for(int i=0;buff[i];i++){ buff[i]=tolower(buff[i]); if(buff[i]=='a'||buf

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

快速切题 poj2488 A Knight&#39;s Journey

A Knight's Journey Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 31195   Accepted: 10668 Description Background The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey ar

快速切题 poj3026

感受到出题人深深的~恶意 这提醒人们以后...数字后面要用gets~不要getchar 此外..不要相信那个100? Borg Maze Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8524   Accepted: 2872 Description The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant o

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

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

快速切题 acdream手速赛(6)A-C

Sudoku Checker Time Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others) SubmitStatisticNext Problem Problem Description Sudoku is a popular single player game. The objective is to fill a 9x9 matrix with digits so that each colu

快速切题 poj1068

Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19716   Accepted: 11910 Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two different ways: q By an integer sequence P = p1 p2...pn

快速切题 poj 2993 Emag eht htiw Em Pleh 模拟

Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2806   Accepted: 1865 Description This problem is a reverse case of the problem 2996. You are given the output of the problem H and your task is to find the correspond

快速切题 poj 2996 Help Me with the Game 模拟暴力

Help Me with the Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3510   Accepted: 2251 Description Your task is to read a picture of a chessboard position and print it in the chess notation. Input The input consists of an ASCII-art