結果

問題 No.36 素数が嫌い!
ユーザー masumasumath1
提出日時 2019-12-08 09:44:03
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,720 ms / 5,000 ms
コード長 512 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-12-29 17:07:18
合計ジャッジ時間 9,035 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#1,素数,自分自身以外で2つの約数を持つか
def hasTwoDivisor(N):
    cnt = 0
    if N == 1:
        return False
    elif N == 2:
        return False
    else:
        i = 2
        while N >= i*i:
            if N%i == 0:
                cnt += 1
                N //= i
                continue #iで割り切れたときは,同じ数でもう一度試す
            i += 1
        return cnt >=2
    return False
N = int(input())
if hasTwoDivisor(N):
    print("YES")
else:
    print("NO")
0