PDA

View Full Version : سوال انگلیسی ACM شماره 1 سال نود



ali_shakeri
شنبه 20 خرداد 1391, 14:55 عصر
Problem A. Long Integers
Time limit: 5 sec
Memory limit: 256 M
Little Kazem is a first grade student. His teacher has given him a homework, and he has to write numbers 1 to 999 in a single row consecutively.
His brother Ghasem wants to verify that Kazem has done his homework correctly. But he doesn’t want to spend much time, so he decides to choose some positions randomly, and verify only those positions. But he doesn’t know how to obtain the digit at that position. So he asks for your help!
Assume that x=1234567...999 where digits are obtained by writing integers to . Your task is to write a program which given finds the digit from left.
Input
First line of input contains a single integer (1<=C<=50). test-cases follow. Each test-case contains a single integer ( 1<=k<=2889).
Output
For each test-case, print a single integer which is equal to .
Sample Input
3
1
11
21
Sample Output
1
0
5
لطفا به همراه تحلیل و تشریح (پیچیدگی مساله) به روش تقسیم و حل و یا حریصانه باشد با تشکر فراوان از شما