-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathURI1216GetlineOne.java
More file actions
128 lines (109 loc) · 3.8 KB
/
URI1216GetlineOne.java
File metadata and controls
128 lines (109 loc) · 3.8 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* See
* <a href="https://www.urionlinejudge.com.br/judge/en/problems/view/1216">Getline
* One</a>
*
* @author Brian Yeicol Restrepo Tangarife
*/
public class URI1216GetlineOne {
static FastScanner in = new FastScanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws IOException {
String line;
double c = 0d;
double avg = 0d;
while ((line = in.nextLine()) != null) {
avg += in.nextDouble();
c++;
}
out.printf("%.1f\n", avg / c);
in.close();
out.close();
}
static class FastScanner implements Closeable {
private final BufferedReader reader;
private StringTokenizer tokenizer;
public FastScanner(InputStream input) {
reader = new BufferedReader(
new InputStreamReader(input));
tokenizer = new StringTokenizer("");
}
public String next() throws IOException {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
String line = nextLine();
if (line == null) {
return null;
}
tokenizer = new StringTokenizer(line);
}
return tokenizer.nextToken();
}
public String nextLine() throws IOException {
tokenizer = null;
return reader.readLine();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public float nextFloat() throws IOException {
return Float.parseFloat(next());
}
public double nextDouble() throws IOException {
return Double.parseDouble(next());
}
public String[] nextStringArray() throws IOException {
return nextLine().split("\\s");
}
public int[] nextIntArray() throws IOException {
String[] stringArray = nextStringArray();
int length = stringArray.length;
int[] array = new int[length];
for (int i = 0; i < stringArray.length; i++) {
array[i] = Integer.parseInt(stringArray[i]);
}
return array;
}
public long[] nextLongArray() throws IOException {
String[] stringArray = nextStringArray();
int length = stringArray.length;
long[] array = new long[length];
for (int i = 0; i < stringArray.length; i++) {
array[i] = Long.parseLong(stringArray[i]);
}
return array;
}
public float[] nextFloatArray() throws IOException {
String[] stringArray = nextStringArray();
int length = stringArray.length;
float[] array = new float[length];
for (int i = 0; i < stringArray.length; i++) {
array[i] = Float.parseFloat(stringArray[i]);
}
return array;
}
public double[] nextDoubleArray() throws IOException {
String[] stringArray = nextStringArray();
int length = stringArray.length;
double[] array = new double[length];
for (int i = 0; i < stringArray.length; i++) {
array[i] = Double.parseDouble(stringArray[i]);
}
return array;
}
@Override
public void close() throws IOException {
tokenizer = null;
reader.close();
}
}
}