- Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathjava.java
More file actions
Latest commit
70 lines (62 loc) · 2.21 KB
/
Copy pathjava.java
File metadata and controls
70 lines (62 loc) · 2.21 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
importjava.util.*;
importjava.math.*;
importjava.io.*;
publicclassMain{
publicstaticvoidmain(String[] args) {
//InputStream inputStream = System.in;
//OutputStream outputStream = System.out;
//文件操作需要抛出异常
try {
InputStreaminputStream = newFileInputStream("discuss.in");
OutputStreamoutputStream = newFileOutputStream("discuss.out");
InputReaderin = newInputReader(inputStream);
PrintWriterout = newPrintWriter(outputStream);
ACsolver = newAC();
solver.solve(in, out);
out.close();
}catch(Exceptione) {
}
}
}
classAC {
InputReaderin;
PrintWriterout;
publicvoidsolve(InputReaderin, PrintWriterout) {
this.in = in; this.out = out;
}
}
classInputReader {
BufferedReaderreader;
StringTokenizertokenizer;
publicInputReader(InputStreamstream) {
reader = newBufferedReader(newInputStreamReader(stream));
tokenizer = null;
//ubuntu 下以ctrl + d终止 while(in.hasNext())
}
publicStringnext() {
if (!hasNext())
thrownewRuntimeException();
returntokenizer.nextToken();
}
booleanhasNext() {
while (tokenizer == null || !tokenizer.hasMoreTokens())
try {
tokenizer = newStringTokenizer(reader.readLine());
} catch (Exceptione) {
returnfalse;
}
returntrue;
}
publicintnextInt() {
returnInteger.parseInt(next());
}
publicdoublenextDouble() {
returnDouble.parseDouble(next());
}
publiclongnextLong() {
returnLong.parseLong(next());
}
publicBigIntegernextBigInteger() {
returnnewBigInteger(next());
}
}