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 |
OMS迅速水过...#include<iostream> #include<vector> using namespace std; int main() { unsigned long a[50000],sum[50000]; int i,n,j,m; vector<int>v; a[0]=sum[0]=0; j=1; for(i=1;i<50000;i++) { a[i]=a[i-1]+j; sum[i]=a[i]+sum[i-1]; if(i==9||i==99||i==999||i==9999) j++; } cin>>n; while(n--) { scanf("%d",&m); i=0; v.clear(); if(m>sum[999]) { if(m>sum[19999]) i=9999; else i=999; } while(m>sum[i]) i++; m-=sum[i-1]; i=0; while(m>a[i]) i++; m-=a[i-1]; while(i) v.push_back(i%10),i/=10; printf("%d\n",*(v.end()-m)); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator