結果

問題 No.36 素数が嫌い!
ユーザー masumasumath1masumasumath1
提出日時 2019-12-08 09:44:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,463 ms / 5,000 ms
コード長 512 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 10,752 KB
実行使用メモリ 7,924 KB
最終ジャッジ日時 2023-08-28 14:57:53
合計ジャッジ時間 7,724 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 358 ms
7,736 KB
testcase_01 AC 41 ms
7,884 KB
testcase_02 AC 15 ms
7,896 KB
testcase_03 AC 14 ms
7,836 KB
testcase_04 AC 15 ms
7,868 KB
testcase_05 AC 17 ms
7,796 KB
testcase_06 AC 17 ms
7,804 KB
testcase_07 AC 19 ms
7,812 KB
testcase_08 AC 14 ms
7,780 KB
testcase_09 AC 14 ms
7,796 KB
testcase_10 AC 14 ms
7,836 KB
testcase_11 AC 482 ms
7,728 KB
testcase_12 AC 1,458 ms
7,700 KB
testcase_13 AC 1,463 ms
7,700 KB
testcase_14 AC 19 ms
7,924 KB
testcase_15 AC 15 ms
7,756 KB
testcase_16 AC 14 ms
7,752 KB
testcase_17 AC 14 ms
7,924 KB
testcase_18 AC 15 ms
7,756 KB
testcase_19 AC 73 ms
7,872 KB
testcase_20 AC 61 ms
7,876 KB
testcase_21 AC 205 ms
7,776 KB
testcase_22 AC 36 ms
7,740 KB
testcase_23 AC 24 ms
7,780 KB
testcase_24 AC 222 ms
7,740 KB
testcase_25 AC 264 ms
7,892 KB
testcase_26 AC 524 ms
7,868 KB
testcase_27 AC 40 ms
7,812 KB
testcase_28 AC 513 ms
7,828 KB
testcase_29 AC 25 ms
7,864 KB
権限があれば一括ダウンロードができます

ソースコード

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