python3 本地运行没问题 第二到第五个RE
查看原帖
python3 本地运行没问题 第二到第五个RE
179501
WNLJOKER楼主2020/8/19 10:12
import math
def isPrime(n):  # 1质数 0不是质数
    m = math.ceil(math.sqrt(n))
    if n<=1:
        return 0
    elif n==2:
        return 1
    else:
        for i in range(2, m+1):
            if n%i == 0: #整除 非质数
                return 0
    return 1
    
 
n = int(input())
line = input()
num_list = list(map(int, line.split(' '))) # input numbers
ans_list = [] # store the prime numbers
for i in range(n):
    if isPrime(num_list[i]):   
        ans_list.append(num_list[i])

print(*ans_list, sep = ' ')
2020/8/19 10:12
加载中...