实现:
import java.util.Scanner;
public class kSmall {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String line=sc.nextLine().trim();
String[] array=line.split(",");
int n=Integer.parseInt(array[0]);
int k=Integer.parseInt(array[1]);
int curr = 1;
k = k - 1;
while (k > 0) {
int steps = calSteps(n, curr, curr + 1);
if (steps <= k) {
curr += 1;
k -= steps;
} else {
curr *= 10;
k -= 1;
}
}
System.out.println(curr);;
}
public static int calSteps(int n, long n1, long n2) {
int steps = 0;
while (n1 <= n) {
steps += Math.min(n + 1, n2) - n1;
n1 *= 10;
n2 *= 10;
}
return steps;
}
}