結果

問題 No.36 素数が嫌い!
ユーザー yakeshiba
提出日時 2020-09-14 17:08:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 196 ms / 5,000 ms
コード長 706 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 82,444 KB
実行使用メモリ 59,036 KB
最終ジャッジ日時 2024-06-22 00:52:36
合計ジャッジ時間 3,132 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

n = int(input())

if n == 1:
    print('NO')
    exit()

fac = factorize(n)

if len(fac) >= 3:
    print('YES')
elif len(fac) == 2:
    if fac[0][1] >= 2 or fac[1][1] >= 2:
        print('YES')
    else:
        print('NO')
else:
    if fac[0][1] >= 2:
        if fac[0][1] == 2 and fac[0][0]**fac[0][1] == n:
            print('NO')
        else:
            print('YES')
    else:
        print('NO')
0