-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA.java
119 lines (115 loc) · 2.77 KB
/
A.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
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
import java.util.*;
import java.io.*;
public class Cipher {
public static void main(String [] args) {
Solver s = new Solver();
s.solve();
}
}
class Solver {
Reader in = new Reader ();
Writer out = new Writer ();
void solve () {
int len = in.nextInt();
String s = in.next();
int n = 0;
for(int i = 1; ; i++) {
if(i * (i + 1) == s.length() * 2) {
n = i;
break;
}
}
int idx = 0;
for(int i = 1; i <= n; i++) {
out.write(s.charAt(idx));
idx += i;
}
out.writeln("");
out.flush();
}
}
class Reader {
private StringTokenizer a;
private BufferedReader b;
Reader () {
a = null;
try {
b = new BufferedReader (new InputStreamReader (System.in)); // for file IO, replace this with new FileReader ("in.txt")
} catch (Exception e) {
e.printStackTrace();
}
}
public String next () {
while(a == null || !a.hasMoreTokens()) {
try {
a = new StringTokenizer (b.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return a.nextToken();
}
public int nextInt() {
return Integer.parseInt(this.next());
}
public long nextLong () {
return Long.parseLong(this.next());
}
public double nextDouble () {
return Double.parseDouble(this.next());
}
public String nextLine() {
try {
return b.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return "";
}
}
class Writer {
private PrintWriter a;
private StringBuffer b;
Writer () {
try {
a = new PrintWriter (System.out); // for file IO, replace this with new FileWriter ("out.txt")
} catch (Exception e) {
e.printStackTrace();
}
b = new StringBuffer ("");
}
public void write (Object s) {
b.append(s);
}
public void writeln(Object s) {
b.append(s).append('\n');
}
public void flush () {
a.print(b);
a.flush();
a.close();
}
}
class Pair implements Comparator <Pair> {
int first;
int second;
Pair (int a, int b) {
this.first = a;
this.second = b;
}
Pair (Pair a) {
this.first = a.first;
this.second = a.second;
}
Pair () {}
public String toString () {
return "[" + first + ", " + second + "]";
}
public int compare (Pair a, Pair b) {
if(a.first == b.first) {
return a.second - b.second;
} else {
return a.first - b.first;
}
}
}