-
Notifications
You must be signed in to change notification settings - Fork 22
/
cointoss.java
52 lines (45 loc) · 1.32 KB
/
cointoss.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.io.*;
import java.util.*;
import java.math.*;
public class cointoss {
private static Reader in;
public static void main (String [] args) throws IOException {
for (int i = (in = new Reader()).nextInt(); i > 0; i--) System.out.printf ("%s.00\n", new BigInteger ("0").setBit (in.nextInt() + 1).subtract (BigInteger.ONE).xor (new BigInteger ("0").setBit (in.nextInt() + 1).subtract (BigInteger.ONE)));
}
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte [] buffer;
private int bufferPointer, bytesRead;
public Reader () {
din = new DataInputStream (System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public int nextInt () throws IOException {
int ret = 0;
byte c = read ();
while (c <= ' ')
c = read ();
boolean neg = (c == '-');
if (neg)
c = read ();
do {
ret = ret * 10 + c - '0';
} while ((c = read ()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
private void fillBuffer () throws IOException {
bytesRead = din.read (buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read () throws IOException {
if (bufferPointer == bytesRead)
fillBuffer ();
return buffer[bufferPointer++];
}
}
}