题解 | #明明的随机数#
明明的随机数
http://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
我这貌似是一种离线的方法,先分割片段正确,再做去重和排序处理。
#多行输入读取
data = []
while True:
try:
num = int(input())
data.append(num)
except:
break
index_slice=0
num_end =0
while num_end <len(data):
sub_data =[]
num_start = index_slice + 1#求分割区间
num_end = num_start + data[index_slice]
#print(num_start,num_end)
sub_data = data[num_start:num_end]#切片数据
uniq = set(sub_data)#去重
for i in sorted(uniq):#输出
print (i)
#print(sub_data)
index_slice = num_end