Find the nth Digit
Time Limit: 1000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 8363 accepted submission (s): 2385
Problem description hypothesis:
S1 = 1
S2 = 12
S3. = 123
S4 = 1234
.........
S9 = 123456789
S10 = 1234567891
S11= 12345678912
............
S18= 123456789123456789
..................
Now we connect all strings
S = 1121231234 ...... 123456789123456789112345678912 .........
Can you tell me the nth number in the S string?
The input is a number K, which indicates K queries.
Each row in the next K Rows has an integer N (1 <=n <2 ^ 31 ).
For each n, output the nth number in S.
Sample Input
61234510
Sample output
112124
Author8600
Sourcehdu 2007-spring Programming Contest-warm up (1) Question: 11 21 2 31 2 3 4 ..... Is to calculate the value of N in the SM range. Because 9 is a cyclic section, MOD 9 is the final result. For example, suppose n = 4, we will find that the value minus the number of the first two layers.
# Include <iostream> using namespace STD; int main () {int t, n; CIN> T; while (t --) {CIN> N; for (INT I = 1; I <n; I ++) N-= I; n = n % 9; If (n) cout <n <Endl; else cout <9 <Endl;} return 0 ;}