快速切题 sgu 112. a^b-b^a 大数 次方 难度:0 非java:1
2014-11-18 22:32
555 查看
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
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); } }
相关文章推荐
- 快速切题 sgu 111.Very simple problem 大数 开平方 难度:0 非java:1
- 快速切题 sgu105. Div 3 数学归纳 数位+整除 难度:0
- 快速切题 sgu115. Calendar 模拟 难度:0
- 【java】BigDecimal、BigInteger、大数相乘、数值的整数次方、快速乘法
- 快速切题 sgu136. Erasing Edges
- 快速切题 sgu118. Digital Root 秦九韶公式
- 快速切题CF 158B taxi 构造 && 82A double cola 数学观察 难度:0
- 快速切题 sgu113 Nearly prime numbers 难度:0
- 快速切题 sgu102.Coprimes 欧拉函数 模板程度 难度:0
- SGU 208 Toral Tickets(Polya计数+Java大数)
- 快速切题 sgu135. Drawing Lines
- sgu-111-111. Very simple problem(java大数)
- a的n次方的快速算法及大数相乘
- 快速切题 poj 1002 487-3279 按规则处理 模拟 难度:0
- 快速切题 poj 1003 hangover 数学观察 难度:0
- 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0
- SGU 407 Number of Paths in the Empire dp+java大数
- sgu 112 a^b - b^a java大数
- 快速切题 sgu116. Index of super-prime bfs+树思想
- 快速切题 poj 2485 Highways prim算法+堆 不完全优化 难度:0