s, sub = input().split() r = False if len(s) < len(sub): s, sub = sub, s for i in range (len(s)): n = s[i:] + s[0:i] if sub in n: r = True print ("true") break if not r: print ("false")
#python代码 def check(s1,s2): len1=len(s1) s1+=s1 if(s1.find(s2)>=0 and s1.find(s2)<len1): return 1 else: return 0
s1,s2=input().split() if(check(s1,s2) or check(s2,s1)): print(“true”) else: print(“false”)
感觉不用全遍历,有更加简单一点的方法QAQ
#python代码
def check(s1,s2):
len1=len(s1)
s1+=s1
if(s1.find(s2)>=0 and s1.find(s2)<len1):
return 1
else:
return 0
s1,s2=input().split()
if(check(s1,s2) or check(s2,s1)):
print(“true”)
else:
print(“false”)
感觉不用全遍历,有更加简单一点的方法QAQ