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 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
Use scanner to TLE
import java.io. *; import java.math.BigInteger; public class Main { public static void main(String args[]) throws IOException { StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); BigInteger a; BigInteger b; in.nextToken(); int A=(int) in.nval; in.nextToken(); int B=(int) in.nval; a=BigInteger.valueOf(A); b=BigInteger.valueOf(B); out.println(a.pow(B).subtract(b.pow(A))); out.flush(); } }
a
while (in.nextToken() != StreamTokenizer.TT_EOF)
My ruby A's posture is so ugly, I want to learn ruby, it's too bad
a=gets.split x=a[0].to_i y=a[1].to_i print x**yy**x