Skip to content

Commit f209b42

Browse files
authored
[20260311] BOJ / G5 / 수 이어 쓰기 2 / 이준희
1 parent b246743 commit f209b42

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
public static void main(String[] args) throws IOException {
7+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8+
StringTokenizer st = new StringTokenizer(br.readLine());
9+
10+
long N = Long.parseLong(st.nextToken());
11+
long K = Long.parseLong(st.nextToken());
12+
13+
long len = 1;
14+
long count = 9;
15+
long num = 0;
16+
17+
while (K > len * count) {
18+
K -= (len * count);
19+
len++;
20+
count *= 10;
21+
}
22+
23+
num = (long)Math.pow(10, len - 1) + (K - 1) / len;
24+
25+
if (num > N) {
26+
System.out.println("-1");
27+
} else {
28+
String s = String.valueOf(num);
29+
System.out.println(s.charAt((int)((K - 1) % len)));
30+
}
31+
}
32+
}
33+
```

0 commit comments

Comments
 (0)