本来各种算以免超时,最后发现直接暴力模拟就过了,才用了42ms。
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
string t;
int main()
{
int T;
cin>>T;
while(T--){
t.clear();
int pos,n=1;
cin>>pos;
t="1";
while(pos>t.size()){
pos-=t.size();
char temp[10];
sprintf(temp,"%d",++n);
t+=temp;
}
cout<<t[pos-1]<<endl;
}
return 0;
}