马虎,又是马虎,生成开始的字符串的时候忘了前导0了,真是!!!!恨!
program yasuo;
const
d:array [1..8] of longint=(1,2,4,8,16,32,64,128);
var
n:longint;
s:ansistring;
function change(x:longint):ansistring;
var
ch:char;
begin
change:='';
if x=0 then exit('00000000');
while x<>0 do
begin
ch:=chr((x mod 2)+48);
change:=ch+change;
x:=x shr 1;
end;
if length(change)<8 then while length(change)<8 do change:='0'+change;
end;
function change1(x:longint):ansistring;
var
i:longint;
ch:char;
begin
change1:='';
if x=0 then exit('00000001');
while x<>0 do
begin
ch:=chr((x mod 2)+48);
change1:=ch+change1;
x:=x shr 1;
end;
if length(change1)<8 then while length(change1)<8 do change1:='0'+change1;
end;
procedure init;
var
i,t:longint;
ts:ansistring;
begin
read(n);
for i:=1 to (n div 8) do
begin
read(t);
ts:=change(t);
s:=s+ts;
end;
end;
procedure print(x:ansistring);
var
ans,i:longint;
begin
ans:=0;
for i:=1 to length(x) do inc(ans,(ord(x[i])-48)*d[length(x)-i+1]);
write(ans,' ');
end;
procedure main;
var
i,len:longint;
ts:ansistring;
begin
i:=1;
while 1=1 do
begin
len:=0;
if s[i]='1' then
begin
while s[i]='1' do
begin
inc(len);
inc(i);
if i>length(s) then break;
end;
ts:=change1(len);
delete(ts,1,1);
insert('1',ts,1);
end
else
begin
while s[i]='0' do
begin
inc(len);
inc(i);
if i>length(s) then break;
end;
ts:=change1(len);
delete(ts,1,1);
insert('0',ts,1);
end;
print(ts);
if i>length(s) then break;
end;
end;
begin
assign(input,'yasuo.in'); reset(input);
assign(output,'yasuo.out'); rewrite(output);
init;
main;
close(input); close(output);
end.