a103: Prime number
Tags :
Accepted rate : 132人/142人 ( 93% ) [非即時]
評分方式:
Strictly

最近更新 : 2022-08-18 01:54

Content

Given a integer 'num' you need to check whether it is a prime number or not.

for each test case there's only one query, so you do not need to build a prime table to optimized your solution just solve it in plain way.

 

In math, prime numbers are whole numbers greater than 1, that have only two factors – 1 and the number itself.

Prime numbers are divisible only by the number 1 or itself.

Input

an Integer num

2<=num<=99999

Output

if num is prime number then print '%d is a prime number' %num

else print '%d is not a prime number' %num

Sample Input #1
2
Sample Output #1
2 is a prime number
Sample Input #2
3
Sample Output #2
3 is a prime number
Sample Input #3
8
Sample Output #3
8 is not a prime number
測資資訊:
記憶體限制: 64 MB
不公開 測資點#0 (33%): 1.0s , <1K
不公開 測資點#1 (33%): 1.0s , <1K
不公開 測資點#2 (34%): 1.0s , <1K
Hint :

when there's exist a factor 'f' then num/'f' is also it's factor, so you only need to check the factors until int(sqrt(num))

Tags:
出處:
[管理者:
kichan@g.pui... (陳嘉賢CHAN KA IN)
]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」