結果
問題 | No.458 異なる素数の和 |
ユーザー | h_noson |
提出日時 | 2017-01-26 13:01:09 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 588 bytes |
コンパイル時間 | 264 ms |
コンパイル使用メモリ | 87,216 KB |
実行使用メモリ | 122,620 KB |
最終ジャッジ日時 | 2023-08-24 23:56:20 |
合計ジャッジ時間 | 15,184 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 76 ms
76,168 KB |
testcase_01 | AC | 625 ms
87,584 KB |
testcase_02 | AC | 827 ms
92,776 KB |
testcase_03 | AC | 192 ms
78,240 KB |
testcase_04 | AC | 226 ms
78,852 KB |
testcase_05 | AC | 1,867 ms
115,440 KB |
testcase_06 | AC | 784 ms
91,760 KB |
testcase_07 | AC | 82 ms
76,256 KB |
testcase_08 | AC | 1,898 ms
115,380 KB |
testcase_09 | AC | 116 ms
77,052 KB |
testcase_10 | AC | 68 ms
71,316 KB |
testcase_11 | TLE | - |
testcase_12 | AC | 70 ms
71,508 KB |
testcase_13 | AC | 69 ms
71,480 KB |
testcase_14 | AC | 69 ms
71,144 KB |
testcase_15 | AC | 68 ms
71,276 KB |
testcase_16 | AC | 143 ms
77,676 KB |
testcase_17 | AC | 69 ms
71,248 KB |
testcase_18 | AC | 70 ms
71,284 KB |
testcase_19 | AC | 69 ms
71,480 KB |
testcase_20 | AC | 70 ms
71,548 KB |
testcase_21 | AC | 67 ms
71,252 KB |
testcase_22 | AC | 69 ms
71,296 KB |
testcase_23 | AC | 69 ms
71,428 KB |
testcase_24 | AC | 68 ms
71,256 KB |
testcase_25 | AC | 68 ms
71,380 KB |
testcase_26 | AC | 69 ms
71,060 KB |
testcase_27 | AC | 731 ms
90,664 KB |
testcase_28 | TLE | - |
testcase_29 | AC | 99 ms
77,164 KB |
testcase_30 | AC | 465 ms
83,072 KB |
ソースコード
def primes(n): is_p = [True for i in range(n+1)] i = 2 while i * i <= n: if is_p[i]: for j in range(i*i,n+1,i): is_p[j] = False i += 1 return [i for i in range(2,n+1) if is_p[i]] n = int(input()) #p = primes(n) mp = {0:0} prime = [True for i in range(n+1)] for i in range(2,n+1): if not prime[i]: continue for j in range(i*i,n+1,i): prime[j] = False tmp = {} for x in mp: if x + i > n: break tmp[x+i] = max(mp[x]+1,mp[x+i] if x+i in mp else -1) mp.update(tmp) print(mp[n] if n in mp else -1)