import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
String m = "";
int []digits=new int[9];
for(int i=1,temp=9;i<9;i++,temp*=10){
digits[i]=digits[i-1]+temp*i;
}
while ((m = br.readLine()) != null) {
int x = Integer.parseInt(m);
if(x==-1)
break;
int index=0;
for(int i=1;i<9;i++){
if(digits[i]>=x){
index=i-1;
break;
}
}
int temp=x-digits[index]-1;
int indAns=temp/(index+1);
int rem=temp%(index+1);
int start=(int) Math.pow(10, index);
String solution=start+indAns+"";
sb.append(solution.charAt(rem)).append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment