Find the nth digit

Source: Internet
Author: User

Find the nth digit
Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 880 Accepted Submission (s): 325
Problem Description hypothesis:
S1 = 1
S2 = 12
S3 = 123
S4 = 1234
.........
S9 = 123456789
S10 = 1234567891
S11 = 12345678912
............
S18 = 123456789123456789
..................
Now we're going to connect all the strings together.
S = 1121231234.......123456789123456789112345678912 .....
So can you tell me what the nth number is in the s string?
Input inputs are first a number k and represent a K-inquiry.
The next K line has an integer n (1 <= n < 2^31) per line.
Output for each n, the number of the nth corresponding to the outputs S.
Sample Input
61234510
Sample Output
112124
Author8600
Sourcehdu 2007-spring Programming Contest-warm up (1)
Recommend8600
/*Add to S65536 length is greater than 2^31.*/#include<bits/stdc++.h>using namespacestd;intMain () {//freopen ("C:\\users\\acer\\desktop\\in.txt", "R", stdin);    Long Longn,t; scanf ("%lld",&t);  while(t--) {scanf ("%lld",&N); Long Longi; Long Longs=0;  for(i=1; s<n;i++) s+=i; Long Longcur=n-s+i-1; if(cur%9) printf ("%d\n", cur%9); Elseputs ("9"); }}

Find the nth digit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.