题解 | #[NOIP2008]笨小猴#
[NOIP2008]笨小猴
http://www.nowcoder.com/practice/17865bc2a75c4944a872ef709958c56e
words = input()
lis = []
for i in words:
lis.append([i, words.count(i)]) # 将字母及对应的出现次数放到嵌套列表里排序
lis.sort(key=lambda x: x[1])
main = lis[-1][1] - lis[0][1] # 取左右两个进行差值计算
if main > 1: # 判断差值是否为质数
for i in range(2, main):
if (main % i) == 0:
print("No Answer")
print("0")
break
else:
print("Lucky Word")
print(main)
else:
print("No Answer")
print("0")
唯一考点是判断质数