Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<algorithm>
- using namespace std;
- int main()
- {
- int q;
- cin >> q;
- for(int Q = 0; Q < q; Q++) {
- long long k;
- cin>>k;
- string n="";
- long long m;
- m=k;
- int i=0;
- long long s=0;
- long long l=9;
- long long p=1;
- long long br=1;
- for(int j=1;j<=18;j++)
- {
- s=s+l*j;
- if(s>k)
- {
- s=s-l*j;
- break;
- }
- p=p*10;
- l=l*10;
- br++;
- }
- if(k == s) {
- cout << 9 << endl;
- continue;
- }
- k-=1;
- long long ost=(k-s)%br;
- p+=(k-s)/br;
- string x = "";
- while(p>0)
- {
- x+=(p%10)+'0';
- p/=10;
- }
- reverse(x.begin(), x.end());
- if(ost==0)
- cout<<x[0] << endl;
- else
- cout<<x[ost] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement