結果
問題 | No.36 素数が嫌い! |
ユーザー | n_knuu |
提出日時 | 2015-05-23 00:53:44 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 959 ms / 5,000 ms |
コード長 | 1,543 bytes |
コンパイル時間 | 639 ms |
コンパイル使用メモリ | 10,932 KB |
実行使用メモリ | 9,244 KB |
最終ジャッジ日時 | 2023-09-09 07:10:51 |
合計ジャッジ時間 | 12,825 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 456 ms
9,040 KB |
testcase_01 | AC | 586 ms
9,120 KB |
testcase_02 | AC | 22 ms
9,040 KB |
testcase_03 | AC | 23 ms
9,136 KB |
testcase_04 | AC | 23 ms
9,212 KB |
testcase_05 | AC | 24 ms
9,036 KB |
testcase_06 | AC | 25 ms
9,040 KB |
testcase_07 | AC | 26 ms
9,112 KB |
testcase_08 | AC | 23 ms
9,044 KB |
testcase_09 | AC | 24 ms
9,092 KB |
testcase_10 | AC | 24 ms
9,132 KB |
testcase_11 | AC | 327 ms
9,084 KB |
testcase_12 | AC | 950 ms
9,016 KB |
testcase_13 | AC | 959 ms
9,204 KB |
testcase_14 | AC | 429 ms
9,072 KB |
testcase_15 | AC | 22 ms
9,080 KB |
testcase_16 | AC | 22 ms
9,192 KB |
testcase_17 | AC | 24 ms
8,912 KB |
testcase_18 | AC | 23 ms
9,108 KB |
testcase_19 | AC | 385 ms
9,192 KB |
testcase_20 | AC | 779 ms
9,188 KB |
testcase_21 | AC | 741 ms
9,148 KB |
testcase_22 | AC | 764 ms
9,128 KB |
testcase_23 | AC | 465 ms
9,128 KB |
testcase_24 | AC | 411 ms
9,040 KB |
testcase_25 | AC | 507 ms
9,112 KB |
testcase_26 | AC | 589 ms
9,128 KB |
testcase_27 | AC | 822 ms
9,228 KB |
testcase_28 | AC | 580 ms
9,188 KB |
testcase_29 | AC | 922 ms
9,244 KB |
ソースコード
# used in ProjectEuler No.12, yukicoder No.36 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 number > 1: 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) ps = d.primeFactors() if len(ps) > 2: print('YES') elif len(ps) == 2: for d, cnt in ps.items(): if cnt > 1: print('YES') break else: print('NO') elif len(ps) == 1: for d, cnt in ps.items(): if cnt > 2: print('YES') break else: print('NO')