同样遇到没做出来 def func(f, l): a = [] for i in l: a.append(i[0]) if f[-1] not in a: return f else: d = "" s = 0 for i in range(len(l)): a = len(d) b = len(l[i]) if l[i][0] == f[-1] and a < b: d = l[i] s = i elif l[i][0] == f[-1] and a == b and sum(ord(l[i][j])*(100**(a-j)) for j in range(a)) < sum(ord(d[j])*(100**(a-j)) for j in range(a)): d = l[i] s = i else: continue f += d l.pop(s) return func(f, l) k = int(input()) n = int(input()) l = [] for i in range(n): l.append(input()) f = l[k] l.pop(k) print(l) print(func(f, l))
点赞 评论

相关推荐

03-16 22:00
武汉大学 C++
幸福的小熊猫想要offer:我阿里投的 c++岗,面试官说自己是做 java 的,c++这辈子才有了
点赞 评论 收藏
分享
牛客网
牛客企业服务