We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents cc1af7a + cc93c58 commit 89a7159Copy full SHA for 89a7159
1 file changed
JHLEE325/202603/12 BOJ G5 수 이어 쓰기 2.md
@@ -0,0 +1,34 @@
1
+```java
2
+import java.io.*;
3
+import java.util.*;
4
+
5
+public class Main {
6
7
+ public static void main(String[] args) throws IOException {
8
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9
+ StringTokenizer st = new StringTokenizer(br.readLine());
10
11
+ long N = Long.parseLong(st.nextToken());
12
+ long K = Long.parseLong(st.nextToken());
13
14
+ long len = 1;
15
+ long count = 9;
16
+ long num = 0;
17
18
+ while (K > len * count) {
19
+ K -= (len * count);
20
+ len++;
21
+ count *= 10;
22
+ }
23
24
+ num = (long)Math.pow(10, len - 1) + (K - 1) / len;
25
26
+ if (num > N) {
27
+ System.out.println("-1");
28
+ } else {
29
+ String s = String.valueOf(num);
30
+ System.out.println(s.charAt((int)((K - 1) % len)));
31
32
33
+}
34
+```
0 commit comments