牛客网编程题——循环单词

在这里插入图片描述
判断循环字符串的简单方法
如果a和b是互为循环字符串
则a in b+b

n = int(input())
res = []
for _ in range(n):
    res.append(input())
all_word = set()
suma = 0
def check(old,this):
    if old in this+this and len(old)==len(this):
        return True
    else:
        return False
for each in res:
    for each_old in all_word:
        if check(each_old,each)==True:
            break
    else:
        all_word.add(each)
        suma += 1
print(suma)
            
        
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页