結果

問題 No.843 Triple Primes
ユーザー kohei2019kohei2019
提出日時 2022-04-23 00:06:36
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 630 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 86,472 KB
最終ジャッジ日時 2023-09-06 11:04:38
合計ジャッジ時間 9,790 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,448 KB
testcase_01 AC 267 ms
86,268 KB
testcase_02 AC 79 ms
76,448 KB
testcase_03 AC 78 ms
76,444 KB
testcase_04 AC 82 ms
76,508 KB
testcase_05 AC 79 ms
76,604 KB
testcase_06 AC 80 ms
76,472 KB
testcase_07 AC 179 ms
84,316 KB
testcase_08 AC 204 ms
85,004 KB
testcase_09 AC 260 ms
86,204 KB
testcase_10 AC 189 ms
84,224 KB
testcase_11 AC 224 ms
85,200 KB
testcase_12 AC 249 ms
86,132 KB
testcase_13 AC 235 ms
85,584 KB
testcase_14 AC 236 ms
85,332 KB
testcase_15 AC 185 ms
84,356 KB
testcase_16 AC 187 ms
84,444 KB
testcase_17 RE -
testcase_18 AC 72 ms
71,576 KB
testcase_19 AC 73 ms
71,816 KB
testcase_20 AC 96 ms
78,272 KB
testcase_21 AC 88 ms
77,164 KB
testcase_22 AC 126 ms
81,500 KB
testcase_23 AC 129 ms
82,036 KB
testcase_24 AC 97 ms
78,712 KB
testcase_25 AC 103 ms
78,032 KB
testcase_26 AC 258 ms
86,312 KB
testcase_27 AC 81 ms
76,524 KB
testcase_28 AC 243 ms
85,640 KB
testcase_29 AC 97 ms
78,872 KB
testcase_30 AC 249 ms
86,068 KB
testcase_31 AC 82 ms
76,892 KB
testcase_32 AC 84 ms
76,780 KB
testcase_33 AC 99 ms
79,112 KB
testcase_34 AC 119 ms
81,036 KB
testcase_35 AC 260 ms
86,472 KB
testcase_36 AC 97 ms
77,632 KB
testcase_37 AC 170 ms
83,940 KB
testcase_38 AC 139 ms
82,376 KB
testcase_39 AC 244 ms
86,260 KB
testcase_40 AC 71 ms
71,712 KB
testcase_41 RE -
testcase_42 AC 198 ms
85,216 KB
testcase_43 AC 220 ms
85,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def primeset(N): #N以下の素数をsetで求める.エラトステネスの篩O(√Nlog(N))
    lsx = [1]*(N+1)
    for i in range(2,int(-(-N**0.5//1))+1):
        if lsx[i] == 1:
            for j in range(i,N//i+1):
                lsx[j*i] = 0
    setprime = set()
    for i in range(2,N+1):
        if lsx[i] == 1:
            setprime.add(i)
    return setprime
    
N = int(input())
setp = primeset(N)
lsp = list(setp)
lsp.sort()
P =len(lsp)
maxp = lsp[-1]
cnt = 0
for k in range(P):
    if lsp[k] ** 2 > maxp*2:
        break
    for j in range(P):
        if (lsp[k]**2 - lsp[j]) in setp:
            cnt += 1
print(cnt)
0