There are all kinds of people in this world. It happens that we have become friends. This is not fate. It is just that we should be friends.

——Green Book

When I first met a problem which name is Find the Nth Character in nowcoder,I find this problem is interesting for mind.After solving this,I find a similar problem like this in HDU which name is find the Nth digit.
Find the Nth Character in nowcoder
find the Nth digit in HDU

Find the Nth Character

Description:
Mr Cheng今天在给HLJU的同学们上程序算法课的时候出了一道找规律的题目，题目表述如下

S=aababcabcdabcde...

6
1
2
3
4
5
10

a
a
b
a
b
d

Code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
int n;
cin>>t;
while (t--)
{
cin>>n;
int a = 1;
char ans='a';
while ( n > a )
{
n -= a;
a++;
}
n%=26;
if(n==0) n=26;
ans+=n-1;
cout<<ans<<endl;
}
return 0;
}


find the nth digit

Description:

S1 = 1
S2 = 12
S3 = 123
S4 = 1234
.........
S9 = 123456789
S10 = 1234567891
S11 = 12345678912
............
S18 = 123456789123456789
..................

S = 1121231234.......123456789123456789112345678912.........

Input

Output

Sample Input
6
1
2
3
4
5
10

Sample Output
1
1
2
1
2
4

Code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
int n;
cin>>t;
while (t--)
{
cin>>n;
int a = 1;
char ans='1';
while ( n > a )
{
n -= a;
a++;
}
n%=9;
if(n==0) n=9;
ans+=n-1;
cout<<ans<<endl;
}
return 0;
}


Intentional analysis:
We can easily find there is a few different between these two codes above.In fact,to solve this problem,the main thinking is find the Nth in the correct position.And the regular is

1 2 3 4 5 6 7 8 9 10...
1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567891...


Through this,you may understand this more.
I know that what I said is not so clearly,so just think through these codes if you can't understand enough.