Problem Link

Here’s my approach from the mathematical Idea being used here to reach the required number from which to pick the particular digit from 9999…

Here’s my code which is leading me to WA for k > 9*13121110987654321

```
#include <bits/stdc++.h>
#define ll unsigned long long
#define vll vector<ll>
using namespace std;
void setIO() {
cin.tie(0)->ios_base::sync_with_stdio(0);
}
void solve() {
vll store = {0,9*1,9*21,9*321,9*4321,9*54321,9*654321,9*7654321,(ll)9*87654321,(ll)9*987654321,(ll)9*10987654321,(ll)9*1110987654321,(ll)9*121110987654321,(ll)9*13121110987654321,(ll)(12718089998888888889)};
vll tens = {1,10,100,1000,(ll)1e4,(ll)1e5,(ll)1e6,(ll)1e7,(ll)1e8,(ll)1e9,(ll)1e10,(ll)1e11,(ll)1e12,(ll)1e13,(ll)1e14};
ll k,i;
cin >> k;
for(i = 1;i <= 14;++i) {
if(store[i] >= k) break;
}
cout << to_string(tens[i]-1-(store[i]-k)/i)[i-1-(store[i]-k)%i] << '\n';
}
int main() {
ll q;
cin >> q;
while(q--) solve();
return 0;
}
```

Please help me know what’s exactly wrong with this code and how can I fix it ?