結果

問題 No.732 3PrimeCounting
ユーザー PNJPNJ
提出日時 2023-07-07 23:18:43
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 520 bytes
コンパイル時間 1,238 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 151,312 KB
最終ジャッジ日時 2023-09-29 01:03:29
合計ジャッジ時間 26,926 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 193 ms
130,572 KB
testcase_01 AC 196 ms
130,476 KB
testcase_02 AC 204 ms
134,844 KB
testcase_03 AC 205 ms
134,856 KB
testcase_04 AC 199 ms
134,928 KB
testcase_05 AC 198 ms
135,172 KB
testcase_06 AC 201 ms
137,992 KB
testcase_07 AC 208 ms
137,904 KB
testcase_08 AC 214 ms
140,524 KB
testcase_09 AC 217 ms
140,520 KB
testcase_10 AC 214 ms
140,952 KB
testcase_11 AC 208 ms
140,708 KB
testcase_12 AC 212 ms
142,208 KB
testcase_13 AC 201 ms
142,208 KB
testcase_14 AC 203 ms
144,224 KB
testcase_15 AC 207 ms
144,148 KB
testcase_16 AC 205 ms
144,040 KB
testcase_17 AC 221 ms
143,888 KB
testcase_18 AC 218 ms
144,040 KB
testcase_19 AC 213 ms
144,008 KB
testcase_20 AC 284 ms
151,312 KB
testcase_21 AC 442 ms
150,832 KB
testcase_22 AC 435 ms
151,060 KB
testcase_23 AC 236 ms
151,100 KB
testcase_24 AC 242 ms
150,928 KB
testcase_25 AC 624 ms
150,860 KB
testcase_26 AC 519 ms
150,984 KB
testcase_27 AC 311 ms
151,072 KB
testcase_28 AC 308 ms
150,952 KB
testcase_29 AC 405 ms
150,968 KB
testcase_30 AC 401 ms
151,000 KB
testcase_31 AC 461 ms
150,840 KB
testcase_32 AC 539 ms
151,052 KB
testcase_33 AC 544 ms
150,976 KB
testcase_34 AC 551 ms
151,144 KB
testcase_35 AC 479 ms
150,984 KB
testcase_36 AC 473 ms
151,136 KB
testcase_37 AC 256 ms
151,044 KB
testcase_38 AC 255 ms
150,940 KB
testcase_39 AC 482 ms
150,804 KB
testcase_40 AC 470 ms
150,960 KB
testcase_41 AC 461 ms
150,728 KB
testcase_42 AC 471 ms
151,208 KB
testcase_43 AC 424 ms
150,976 KB
testcase_44 AC 420 ms
150,976 KB
testcase_45 AC 331 ms
150,952 KB
testcase_46 AC 334 ms
150,952 KB
testcase_47 AC 372 ms
151,276 KB
testcase_48 AC 649 ms
150,856 KB
testcase_49 AC 651 ms
151,004 KB
testcase_50 AC 434 ms
150,960 KB
testcase_51 AC 448 ms
151,284 KB
testcase_52 AC 313 ms
151,040 KB
testcase_53 AC 1,014 ms
151,248 KB
testcase_54 TLE -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

def eratosthenes(N):
    P = []
    d = defaultdict(int)
    for p in range(2,N+1):
        if d[p] == 1:
            continue
        P.append(p)
        for q in range(1,N//p+1):
            d[p*q] = 1
    return P

d = defaultdict(int)
N = int(input())
P = eratosthenes(300000)
Q = [2]
S = []
ans = 0
for i in range(2,len(P)):
  c = P[i]
  if c > N:
    break
  for p in Q:
    q = p + P[i-1]
    d[q] += 1
  Q.append(P[i-1])
  for p in P:
    q = p - c
    ans += d[q]
print(ans)
0