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 lydliyudong at 2011-04-04 21:11:34 on Problem 1019
In Reply To:是一个配方题 Posted by:custqi at 2011-02-26 08:31:37
var
 f:array[0..99999]of int64;
 t,n,i,j,k:longint;
 m:int64;
 s:ansistring;
begin
 for i:=1 to 9 do f[i]:=f[i-1]+1;
 for i:=10 to 99 do f[i]:=f[i-1]+2;
 for i:=100 to 999 do f[i]:=f[i-1]+3;
 for i:=1000 to 9999 do f[i]:=f[i-1]+4;
 for i:=10000 to 99999 do f[i]:=f[i-1]+5;
 readln(t);
 for i:=1 to t do
  begin
   readln(n);
   m:=0; j:=0;
   while m<n do
    begin
     inc(j);
     inc(m,f[j]);
    end;
   dec(m,f[j]);
   for k:=1 to j do
    begin
     str(k,s);
     inc(m,length(s));
     if m>=n then break;
    end;
   dec(m,length(s));
   writeln(s[n-m]);
  end;
end.

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