Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
水过~~~~贴代码~~~~~~~~~~~~~~~~~#include<iostream> #include<string> #include<algorithm> using namespace std; inline string tostr(int x) { string s; //int temp=0; while(x){ s.push_back(x%10+'0'); x/=10; } reverse(s.begin(),s.end()); return s; } int main( ) { // freopen("i.txt","r",stdin); // freopen("o.txt","w",stdout); long long pos,t; cin>>t; while(t--){ cin>>pos; long long top=2,len=1; string s="1",temp="1"; while(len<pos){ temp+=tostr(top); len+=temp.length(); top++; } cout<<temp[temp.length()-(len-pos)-1]<<endl; } // system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator