| ||||||||||
| 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 | |||||||||
1019-谁能帮我看看为什么总是WA啊program pku1019;
var i,c,n:longint;
a,b:array[0..9] of longint;
procedure init;
var i:integer;
u:longint;
begin
a[0]:=0;b[0]:=0;
for i:=1 to 3 do
begin
u:=10**i-10**(i-1);
b[i]:=u*(b[i-1]+i)+((u-1)div 2)*u*i;
end;
for i:=1 to 8 do
a[i]:=(10**i-10**(i-1))*i+a[i-1];
end;
procedure make(input:longint);
var i,k,left,thenum,p:longint;
s:string;
begin
for i:=1 to 8 do
if (input>a[i-1]) and (input<=a[i])
then k:=i;
left:=input-a[k-1];
if (left mod k)=0 then thenum:=10**(k-1)-1+left div k
else thenum:=10**(k-1)+left div k;
p:=left mod k;
if p=0 then p:=k;
str(thenum,s);
write(s[p]);
end;
procedure solve(input:longint);
var i,k:longint;
now,left:longint;
begin
for i:=1 to 4 do
if (input>b[i-1]) and (input<=b[i])
then k:=i;
if input>b[3] then k:=4;
left:=input-b[k-1];
now:=10**(k-1)-1+k;
while (left-now>0) do
begin
left:=left-now;
now:=now+k;
end;
make(left);
end;
begin
init;
readln(c);
for i:=1 to c do begin
readln(n);
solve(n);
end;
end.
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator