We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b246743 commit f209b42Copy full SHA for f209b42
1 file changed
JHLEE325/202603/12 BOJ G5 수 이어 쓰기 2.md
@@ -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