| ||||||||||
| 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 | |||||||||
谁能帮忙查查这程序为何总是Runtime error,多谢了RT
program poj2886;
const antiprime:array[1..37] of longint=(1,2,4,6,12,24,36,48,60,120,180,240,360,720,840,1260,1680,2520,5040,7560,10080,15120,20160,25200,27720,45360,50400,55440,83160,110880,166320, 221760, 277200, 332640, 498960, 554400, 665280);
factorNum:array[1..37] of integer=(1, 2, 3, 4, 6, 8, 9, 10, 12, 16, 18, 20, 24, 30, 32, 36, 40, 48, 60, 64, 72, 80, 84, 90, 96, 100, 108, 120, 128, 144, 160, 168, 180, 192, 200, 216, 224);
var tree:array[0..4*500001] of record l,r,space:longint; end;
next:array[0..500001] of longint;
name:array[0..500001] of string[12];
i,t,k,kk,num,n:longint;
ch:char;
procedure maketree(k,l,r:longint);
begin
tree[k].l:=l; tree[k].r:=r; tree[k].space:=r-l;
if l+1<r then
begin
maketree(k shl 1,l,(l+r) shr 1);
maketree(k shl 1+1,(l+r) shr 1,r);
end;
end;
procedure insert(k,x:longint);
begin
with tree[k] do
begin
dec(space);
if l+1=r then begin kk:=r; exit; end;
if x<=tree[k shl 1].space
then insert(k shl 1,x)
else insert(k shl 1+1,x-tree[k shl 1].space);
end;
end;
begin
assign(input,'input.txt'); reset(input);
assign(output,'output.txt'); rewrite(output);
readln(n,k);
for i:=1 to n do
begin
read(ch); name[i]:='';
while ch<>' ' do
begin
name[i]:=name[i]+ch;
read(ch);
end;
readln(next[i]);
end;
maketree(1,0,n);
t:=1;
while antiprime[t]<n do inc(t);
num:=antiprime[t];
kk:=0; next[kk]:=0;
while num>0 do
begin
dec(num);
if (next[kk]>0) then k:=((k+next[kk]-2) mod n+n) mod n+1
else k:=((k+next[kk]-1) mod n+n) mod n+1;
insert(1,k);
dec(n);
end;
writeln(name[kk],' ',factornum[t]);
close(input); close(output);
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator