program sequence;
const
infns = 'input.txt';
outfns = 'output.txt';
type
Tarr = array [1..6] of integer;
Tdata = array [0..1000] of Word;
var
p,w
data :Tdata;
n :word;
procedure init; {读入过程}
var
inf :text;
a0,b0,l0,a1,b1,l1,i:Integer;
begin
assign(inf,infns);
reset(inf);
readln(inf,n,a0,b0,l0,a1,b1,l1);
close(inf);
p[1]:=1; p[2]:=-1; p[3]:=l0; p[4]:=-l0; p[5]:=l1; p[6]:=-l1;
w[1]:=1; w[2]:=0; w[3]:=l0-a0; w[4]:=-(l0-b0); w[5]:=b1; w[6]:=-a1;
fillchar(data,sizeof(data),$a);
data[0]:=0;
end;
procedure main;
var
finish :Boolean;
i,j :Word;
begin
repeat
finish:=True;
for i:=0 to n-1 do
for j:=1 to 6 do
if (i+p[j]<=n) and (i+p[j]>0) and (data[i]+w[j]<data[i+p[j]])
and (data[i]+w[j]>=0)
then begin finish:=false; data[i+p[j]]:=data[i]+w[j];
end;
until finish;
end;
procedure out;
var
i :Word;
begin
assign(output,outfns);
rewrite(output);
if data[n]=2570
then writeln(-1)
else
begin
write(0);
for i:=1 to n-1 do
write(data[i]-data[i-1]);
writeln;
end;
close(output);
end;
begin
init;
main;
out;
program sort;
type
Tdata = array [1..10000] of Word;
var
data :Tdata;
n,k :Word;
procedure out(x:Word);
begin
writeln(data[x]);
halt;
end;
procedure swap(var a,b:Word);
var
tmp :Word;
begin
tmp:=a;
a:=b;
b:=tmp;
end;
procedure get_mid(head,tail:integer;var x:integer);
var
i,j :integer;
m :Word;
begin
i:=head+random(tail-head+1);
swap(data[head],data[i]);
i:=head-1; j:=tail+1; m:=data[head];
while true do
begin
repeat j:=j-1;
until data[j]<=m;
repeat i:=i+1;
until data[i]>=m;
if i>=j
then
begin
x:=j;
exit;
end
else swap(data[i],data[j]);
end;
end;
procedure quicksort(head,tail:integer);
x :integer;
begin
if head>tail then exit;
get_mid(head,tail,x);
if x>k then quicksort(head,x)
else if x<k then quicksort(x+1,tail)
else out(x);
end;
procedure init;
var
i :Word;
begin
assign(input,'input.txt');
reset(input);
readln(n,k);
for i:=1 to n do
readln(data[i]);
close(input);
end;
begin
init;
quicksort(1,n);
program max;
var m,n,next,k :longint;
begin
write('K= '); readln(k);
if (k<1) or (k>1000000000) then halt;
m:=1; n:=1; next:=m+n;
while next<=k do
begin
m:=n;
n:=next;
next:=m+n;
end;
writeln('M= ',m); writeln('N= ',n);
又试了试别的,还是不成,都四个多小时了,我真疯了,拜托各位了……