level 2
var
s:ansistring;
a:array[0..256]of longint;
i,n:longint;
function fbi(s,e:longint):ansistring;
var
mid:longint;
begin
if s=e then
begin
if a[e]-a[s-1]=0 then fbi:='B';
if a[e]-a[s-1]=e-s+1 then fbi:='I'
end
else begin
mid:=(s+e) div 2;
fbi:=fbi(s,mid)+fbi(mid+1,e)+'F';
end;
end;
begin
readln(n);
readln(s);
n:=length(s);
a[0]:=0;
for i:=1 to n do
a[i]:=a[i-1]+ord(s[i])-ord('0');
writeln(fbi(1,n));
end.
求查错
2014年04月20日 12点04分
1
s:ansistring;
a:array[0..256]of longint;
i,n:longint;
function fbi(s,e:longint):ansistring;
var
mid:longint;
begin
if s=e then
begin
if a[e]-a[s-1]=0 then fbi:='B';
if a[e]-a[s-1]=e-s+1 then fbi:='I'
end
else begin
mid:=(s+e) div 2;
fbi:=fbi(s,mid)+fbi(mid+1,e)+'F';
end;
end;
begin
readln(n);
readln(s);
n:=length(s);
a[0]:=0;
for i:=1 to n do
a[i]:=a[i-1]+ord(s[i])-ord('0');
writeln(fbi(1,n));
end.
求查错