結果

問題 No.36 素数が嫌い!
ユーザー roarisroaris
提出日時 2019-08-08 11:22:20
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 959 ms / 5,000 ms
コード長 694 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,800 KB
実行使用メモリ 7,876 KB
最終ジャッジ日時 2023-09-25 23:50:47
合計ジャッジ時間 13,318 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 453 ms
7,824 KB
testcase_01 AC 586 ms
7,812 KB
testcase_02 AC 16 ms
7,816 KB
testcase_03 AC 15 ms
7,872 KB
testcase_04 AC 16 ms
7,768 KB
testcase_05 AC 18 ms
7,768 KB
testcase_06 AC 19 ms
7,784 KB
testcase_07 AC 18 ms
7,820 KB
testcase_08 AC 17 ms
7,772 KB
testcase_09 AC 18 ms
7,776 KB
testcase_10 AC 18 ms
7,804 KB
testcase_11 AC 323 ms
7,776 KB
testcase_12 AC 959 ms
7,768 KB
testcase_13 AC 954 ms
7,816 KB
testcase_14 AC 424 ms
7,876 KB
testcase_15 AC 16 ms
7,776 KB
testcase_16 AC 17 ms
7,748 KB
testcase_17 AC 16 ms
7,824 KB
testcase_18 AC 16 ms
7,748 KB
testcase_19 AC 384 ms
7,820 KB
testcase_20 AC 772 ms
7,776 KB
testcase_21 AC 735 ms
7,772 KB
testcase_22 AC 756 ms
7,724 KB
testcase_23 AC 460 ms
7,828 KB
testcase_24 AC 407 ms
7,820 KB
testcase_25 AC 502 ms
7,776 KB
testcase_26 AC 586 ms
7,776 KB
testcase_27 AC 822 ms
7,752 KB
testcase_28 AC 569 ms
7,788 KB
testcase_29 AC 926 ms
7,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def factorize(n):
    if n == 1:
        return [(1, 1)]
        
    factors = []
    
    for div in range(2, int(n**0.5) + 1):
        cnt = 0
        while n % div == 0:
            n //= div
            cnt += 1
        if cnt > 0:
            factors.append((div, cnt))
    
    if n > 1:
        factors.append((n, 1))
    
    return factors

N = int(input())
factors = factorize(N)

if len(factors) == 1:
    _, cnt = factors[0]
    
    if cnt >= 3:
        print('YES')
    else:
        print('NO')
elif len(factors) == 2:
    _, cnt1 = factors[0]
    _, cnt2 = factors[1]
    
    if cnt1 >= 2 or cnt2 >= 2:
        print('YES')
    else:
        print('NO')
else:
    print('YES')
0