結果

問題 No.843 Triple Primes
ユーザー ssmkzkssmkzk
提出日時 2019-07-02 14:07:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 589 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 28,252 KB
最終ジャッジ日時 2023-09-28 21:12:00
合計ジャッジ時間 6,372 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,216 KB
testcase_01 AC 175 ms
28,252 KB
testcase_02 AC 19 ms
8,536 KB
testcase_03 AC 18 ms
8,024 KB
testcase_04 AC 20 ms
8,664 KB
testcase_05 AC 19 ms
8,156 KB
testcase_06 AC 20 ms
8,640 KB
testcase_07 AC 142 ms
24,168 KB
testcase_08 AC 148 ms
25,872 KB
testcase_09 AC 170 ms
28,152 KB
testcase_10 AC 139 ms
24,972 KB
testcase_11 AC 157 ms
26,648 KB
testcase_12 AC 167 ms
27,704 KB
testcase_13 AC 159 ms
27,228 KB
testcase_14 AC 166 ms
27,180 KB
testcase_15 AC 136 ms
24,568 KB
testcase_16 AC 139 ms
24,896 KB
testcase_17 WA -
testcase_18 AC 18 ms
8,036 KB
testcase_19 AC 17 ms
8,096 KB
testcase_20 AC 51 ms
13,584 KB
testcase_21 AC 37 ms
11,060 KB
testcase_22 AC 95 ms
19,492 KB
testcase_23 AC 97 ms
19,812 KB
testcase_24 AC 54 ms
13,844 KB
testcase_25 AC 44 ms
12,344 KB
testcase_26 AC 169 ms
28,132 KB
testcase_27 AC 24 ms
9,304 KB
testcase_28 AC 166 ms
27,432 KB
testcase_29 AC 55 ms
14,376 KB
testcase_30 AC 168 ms
27,804 KB
testcase_31 AC 28 ms
9,868 KB
testcase_32 AC 24 ms
9,324 KB
testcase_33 AC 62 ms
14,900 KB
testcase_34 AC 89 ms
18,532 KB
testcase_35 AC 171 ms
28,220 KB
testcase_36 AC 41 ms
12,228 KB
testcase_37 AC 131 ms
23,672 KB
testcase_38 AC 109 ms
21,188 KB
testcase_39 AC 168 ms
27,652 KB
testcase_40 AC 18 ms
8,156 KB
testcase_41 WA -
testcase_42 AC 140 ms
25,336 KB
testcase_43 AC 167 ms
26,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import bisect

N = int(input())

def SoE(x):
    if x < 2:
        return []
    
    l = [i for i in range(x + 1)]
    l[1] = 0
    
    for i in l:
        if i > math.sqrt(x):
            break
        if i == 0:
            continue
        for j in range(2 * i , x + 1, i):
            l[j] = 0
    
    return [i for i in l if i != 0]

def index(a, x):
    i = bisect.bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return 2
    else:
        return 0

prime = SoE(N)
ans = 0
for l_i in prime:
    a = pow(l_i,2) - 2
    ans += index(prime,a)

print(ans - 1)
0