結果

問題 No.36 素数が嫌い!
ユーザー n_knuun_knuu
提出日時 2015-05-23 00:27:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,227 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 11,012 KB
実行使用メモリ 9,296 KB
最終ジャッジ日時 2023-09-20 10:17:55
合計ジャッジ時間 12,657 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 586 ms
9,228 KB
testcase_02 AC 22 ms
9,176 KB
testcase_03 AC 21 ms
9,104 KB
testcase_04 AC 21 ms
9,212 KB
testcase_05 AC 24 ms
9,104 KB
testcase_06 AC 24 ms
9,152 KB
testcase_07 AC 24 ms
9,248 KB
testcase_08 AC 23 ms
9,220 KB
testcase_09 AC 23 ms
9,060 KB
testcase_10 WA -
testcase_11 AC 327 ms
9,064 KB
testcase_12 AC 950 ms
9,228 KB
testcase_13 AC 953 ms
9,064 KB
testcase_14 WA -
testcase_15 AC 22 ms
9,228 KB
testcase_16 AC 22 ms
9,088 KB
testcase_17 AC 22 ms
9,004 KB
testcase_18 AC 22 ms
9,148 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 409 ms
9,056 KB
testcase_25 WA -
testcase_26 AC 591 ms
9,148 KB
testcase_27 AC 817 ms
9,240 KB
testcase_28 AC 580 ms
9,204 KB
testcase_29 AC 920 ms
9,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import deepcopy
from functools import reduce

class Divisor:
    def __init__(self, n):
        """ make divisors list and prime factorization list of n"""
        number = n
        if number == 1:
            self.primeFactorization = {1: 1}
        else:
            self.primeFactorization = {}
            for i in range(2, int(n**0.5)+1):
                cnt = 0
                while number % i == 0:
                    cnt += 1;
                    number //= i
                if cnt > 0:
                    self.primeFactorization[i] = cnt
            if len(self.primeFactorization) == 0:
                self.primeFactorization[n] = 1

    def primeFactors(self):
        return deepcopy(self.primeFactorization)

    def numDivisors(self):
        """ the number of divisors """
        if self.primeFactorization.get(1, 0) == 1:
            return 1
        numDiv = 1
        for _, cnt in self.primeFactorization.items():
            numDiv *= cnt+1
        return numDiv

    def sumDivisors(self):
        return reduce(lambda x, y: x * y, [sum(p**i for i in range(n+1)) for p, n in self.primeFactorization.items()])

N = int(input())
d = Divisor(N)
print('YES' if d.numDivisors() >= 5 else 'NO')
0