結果

問題 No.36 素数が嫌い!
ユーザー momoyuumomoyuu
提出日時 2022-08-03 00:26:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 234 ms / 5,000 ms
コード長 551 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 75,760 KB
最終ジャッジ日時 2023-10-01 01:06:15
合計ジャッジ時間 6,532 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
75,424 KB
testcase_01 AC 189 ms
75,432 KB
testcase_02 AC 73 ms
71,072 KB
testcase_03 AC 73 ms
71,328 KB
testcase_04 AC 79 ms
71,260 KB
testcase_05 AC 83 ms
75,316 KB
testcase_06 AC 84 ms
75,676 KB
testcase_07 AC 82 ms
75,420 KB
testcase_08 AC 84 ms
75,252 KB
testcase_09 AC 83 ms
75,676 KB
testcase_10 AC 86 ms
75,416 KB
testcase_11 AC 131 ms
75,256 KB
testcase_12 AC 223 ms
75,748 KB
testcase_13 AC 218 ms
75,252 KB
testcase_14 AC 184 ms
75,616 KB
testcase_15 AC 80 ms
71,240 KB
testcase_16 AC 80 ms
71,368 KB
testcase_17 AC 79 ms
70,768 KB
testcase_18 AC 77 ms
75,656 KB
testcase_19 AC 133 ms
75,760 KB
testcase_20 AC 218 ms
75,624 KB
testcase_21 AC 186 ms
75,624 KB
testcase_22 AC 192 ms
75,588 KB
testcase_23 AC 148 ms
75,652 KB
testcase_24 AC 152 ms
75,416 KB
testcase_25 AC 152 ms
75,552 KB
testcase_26 AC 164 ms
75,744 KB
testcase_27 AC 216 ms
75,720 KB
testcase_28 AC 163 ms
75,260 KB
testcase_29 AC 234 ms
75,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
if N == 1:
    print("NO")
    exit()

import math
m = math.floor(math.sqrt(N))
d = {}

for i in range(2,m):
    while N % i == 0:
        if not i in d:
            d[i] = 0
        d[i] += 1
        N //= i
if not N == 1:
    if not N in d:
        d[N] = 0
    d[N] += 1

a = 0
b = 0
for i in d:
    if d[i] >= 3:
        print("YES")
        exit()
    if d[i] == 2:
        a += 1
    elif d[i] == 1:
        b += 1
if a >= 2 or (a == 1 and b != 0):
    print("YES")
    exit()
if b >= 3:
    print("YES")
    exit()
print("NO")
0