forked from NASU41/AtCoderLibraryForJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContestPrinter.java
More file actions
92 lines (85 loc) · 2.47 KB
/
ContestPrinter.java
File metadata and controls
92 lines (85 loc) · 2.47 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class ContestPrinter extends java.io.PrintWriter{
public ContestPrinter(java.io.PrintStream stream){
super(stream);
}
public ContestPrinter(){
super(System.out);
}
private static String dtos(double x, int n) {
StringBuilder sb = new StringBuilder();
if(x < 0){
sb.append('-');
x = -x;
}
x += Math.pow(10, -n)/2;
sb.append((long)x);
sb.append(".");
x -= (long)x;
for(int i = 0;i < n;i++){
x *= 10;
sb.append((int)x);
x -= (int)x;
}
return sb.toString();
}
@Override
public void print(float f){
super.print(dtos(f, 20));
}
@Override
public void println(float f){
super.println(dtos(f, 20));
}
@Override
public void print(double d){
super.print(dtos(d, 20));
}
@Override
public void println(double d){
super.println(dtos(d, 20));
}
public void printArray(int[] array, String separator){
int n = array.length;
for(int i=0; i<n-1; i++){
super.print(array[i]);
super.print(separator);
}
super.println(array[n-1]);
}
public void printArray(int[] array){
this.printArray(array, " ");
}
public void printArray(int[] array, String separator, java.util.function.IntUnaryOperator map){
int n = array.length;
for(int i=0; i<n-1; i++){
super.print(map.applyAsInt(array[i]));
super.print(separator);
}
super.println(array[n-1]);
}
public void printArray(int[] array, java.util.function.IntUnaryOperator map){
this.printArray(array, map);
}
public void printArray(long[] array, String separator){
int n = array.length;
for(int i=0; i<n-1; i++){
super.print(array[i]);
super.print(separator);
}
super.println(array[n-1]);
}
public void printArray(long[] array){
this.printArray(array, " ");
}
public void printArray(long[] array, String separator, java.util.function.LongUnaryOperator map){
int n = array.length;
for(int i=0; i<n-1; i++){
super.print(map.applyAsLong(array[i]));
super.print(separator);
}
super.println(array[n-1]);
}
public void printArray(long[] array, java.util.function.IntUnaryOperator map){
this.printArray(array, map);
}
}