luyifly @ 2024-11-10 23:09:20
求助 代码如下
#初始化数据
s=list(input())
distin=count=0
out=[]
#循环录入
for x in s:
if x==' ':
continue
elif int(x)==distin:
count+=1
else:
out.append(count)
count=1
distin=(distin+1)%2
#录入最后一个值
out.append(count)
#输出板块
print(int(sum(out)**0.5),end=' ')#输出方阵边长
#输出后续压缩码
for x in out:
print(x,end=' ')
输入1: 0001000 0001000 0001111 0001000 0001000 0001000 1111111
输出1:7 3 1 6 1 6 4 3 1 6 1 6 1 3 7
输入2:11111 00100 11111 00100 11111
输出2:5 0 5 2 1 2 5 2 1 2 5
感谢
by hubosheng @ 2024-11-29 20:42:29
你这输出不对啊