讨论 / Python AC
a742622195 2018-09-16 23:11:34
点我顶贴 收藏 删除
#!/usr/bin/python

from functools import reduce

def handlerNum(num):

if num > 1:

for i in range(2, num//2+1):

if (num % i) == 0:

return 0

return 1

def hs(n,m,list):

if n==1:return map(int,list)

list=[s+str(i) for s in list for i in range(1,m+1) if str(i) not in s]

return hs(n-1,m,list)

while True:

try:

n,m=map(int,raw_input().strip().split())

list=hs(n,m,map(str,range(1,m+1)))

list=[num for num in list if handlerNum(num) ]

if not list:

print 0

else:

ln = reduce(lambda x,y:x * y,list)

print ln

except EOFError:

break

查看更多回复
提交回复