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 <vector> using namespace std; unsigned int n,x,p,i,t,F[31269]={0,1}; char m[9]; vector<char> a(1,'1'); int main() { for(i=2;i<31269;i++){ t=0; x=i; while(1){ m[t++]=x%10+'0'; if(!(x/=10))break; } F[i]=F[i-1]*2-F[i-2]+t; while(t--)a.push_back(m[t]); } cin>>n; while(n--){ cin>>x; for(i=1;i<31269;i++)if(x<=F[i])break; p=x-F[i-1]; cout<<a[p-1]<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator