分享一下python版的AC代码 第一题 def isCon(s, tem): n, k = len(s), len(tem) if n % k != 0: return False i = 0 while i < n-k+1: if tem != s[i:i+k]: return False i += k return True def f(s1, s2): if len(s1) > len(s2): s1, s2 = s2, s1 # s1的长度不大于s2的长度 m, n = len(s1), len(s2) if m == n: return s1 if s1 == s2 else "" res = "" for i in range(1, n-m+1): if (n-m) % i == 0: tem = s1[:i] if isCon(s1, tem) and isCon(s2, tem): res = tem return res s1 = input() s2 = input() out = f(s1, s2) print(out)