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 |
纯数据操作,不做表格O(logn)时间小弟的思路: 1.逐次减去区间长度,得到最后区间1.....m的长度 2.逐次减去能减去的最大区间如1....m-1的长度 得到最终的若干位,通过字符输出 16MS #include <iostream> #include <stdlib.h> #include <cmath> using namespace std; int main() { char rst[20]; int length[100000], t, test, maxi; cin >> t; memset(length, 0, sizeof(length)); while (t--) { cin >> test; int temp, rsti, tempi; maxi = 1; temp = test; while (temp > length[maxi-1]) { temp -= length[maxi-1]; length[maxi] = length[maxi-1] + (int)log10((double)maxi) + 1; maxi++; } rsti = 0; tempi = 1; while (1) { rsti += (int)log10((double)tempi) + 1; if (rsti == temp) {rsti = (int)log10((double)tempi);break;} else if (rsti > temp) {rsti -= temp; rsti = ((int)log10((double)tempi))- rsti; break;} tempi++; } _itoa_s(tempi, rst, 10); cout << rst[rsti] << 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