Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

水过~~~~贴代码~~~~~~~~~~~~~~~~~

Posted by qibinlou at 2012-08-10 16:23:41 on Problem 1019
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator