主题:大家看看偶错哪了?有加分~~~~~
kitty的基因编码如下定义: kitty的基因由一串长度2^k(k<=8)的01序列构成,为了方便研究,需要把,01序列转换为ABC编码。用T(s)来表示01序列s的ABC编码 T(s)=‘A'(当S全由'0'组成) T(s)=‘B'(当s全由'1'组成) T(s)=‘C'+T(s1)+T(s2) s1,s2为把s等分为2个长度相等的子串 比如 T('00')='A' T('00001111')='CAB'
Input
一行,长度为2^k,为kitty猫的01基因编码,有多个数据
Output
一行,由ABC构成的ABC编码
Sample Input
01001011
Sample Output
CCCABACCBAB
var
s:string;
procedure f(k:string);
var
i,a,b:integer;
p:string;
begin
a:=0;
b:=0;
for i:=1 to length(k) do
if k[i]='0'
then a:=a+1
else b:=b+1;
if a=length(k)
then write('A')
else if b=length(k)
then write('B')
else begin
write('C');
p:=copy(k,1,length(k)div 2);
f(p);
p:=copy(k,(length(k) div 2) +1,length(k) div 2);
f(p);
end;
end;
begin
read(s);
f(s);
end.
Input
一行,长度为2^k,为kitty猫的01基因编码,有多个数据
Output
一行,由ABC构成的ABC编码
Sample Input
01001011
Sample Output
CCCABACCBAB
var
s:string;
procedure f(k:string);
var
i,a,b:integer;
p:string;
begin
a:=0;
b:=0;
for i:=1 to length(k) do
if k[i]='0'
then a:=a+1
else b:=b+1;
if a=length(k)
then write('A')
else if b=length(k)
then write('B')
else begin
write('C');
p:=copy(k,1,length(k)div 2);
f(p);
p:=copy(k,(length(k) div 2) +1,length(k) div 2);
f(p);
end;
end;
begin
read(s);
f(s);
end.