看这个图应该会更清楚一些 while True: try: a=input().split()[1:] b=map(str,sorted(map(int,set(input().split()[1:])))) totalNum=0 res="" for num in b: singleRes,count="",0 for i,v in enumerate(a): if num in v: ...