結果

問題 No.843 Triple Primes
ユーザー 👑 H20H20
提出日時 2021-01-07 10:37:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 649 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 90,496 KB
最終ジャッジ日時 2024-04-25 12:44:54
合計ジャッジ時間 5,502 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,096 KB
testcase_01 AC 140 ms
89,984 KB
testcase_02 AC 47 ms
61,312 KB
testcase_03 AC 46 ms
60,928 KB
testcase_04 AC 46 ms
61,312 KB
testcase_05 AC 46 ms
61,184 KB
testcase_06 AC 47 ms
61,696 KB
testcase_07 AC 117 ms
84,480 KB
testcase_08 AC 128 ms
86,912 KB
testcase_09 AC 145 ms
90,496 KB
testcase_10 AC 122 ms
86,528 KB
testcase_11 AC 135 ms
89,344 KB
testcase_12 AC 144 ms
89,856 KB
testcase_13 AC 139 ms
89,600 KB
testcase_14 AC 139 ms
89,344 KB
testcase_15 AC 124 ms
86,400 KB
testcase_16 AC 119 ms
86,400 KB
testcase_17 AC 35 ms
52,096 KB
testcase_18 WA -
testcase_19 AC 35 ms
52,224 KB
testcase_20 AC 68 ms
69,120 KB
testcase_21 AC 56 ms
65,408 KB
testcase_22 AC 92 ms
78,848 KB
testcase_23 AC 95 ms
78,976 KB
testcase_24 AC 73 ms
69,504 KB
testcase_25 AC 68 ms
67,712 KB
testcase_26 AC 147 ms
90,112 KB
testcase_27 AC 49 ms
62,464 KB
testcase_28 AC 134 ms
89,728 KB
testcase_29 AC 70 ms
70,400 KB
testcase_30 AC 138 ms
90,240 KB
testcase_31 AC 52 ms
63,872 KB
testcase_32 AC 49 ms
62,592 KB
testcase_33 AC 76 ms
71,808 KB
testcase_34 AC 110 ms
75,904 KB
testcase_35 AC 142 ms
90,240 KB
testcase_36 AC 61 ms
66,688 KB
testcase_37 AC 113 ms
84,096 KB
testcase_38 AC 101 ms
81,536 KB
testcase_39 AC 154 ms
89,856 KB
testcase_40 WA -
testcase_41 AC 36 ms
51,840 KB
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table

N = int(input())
_,t = sieve(2*N)
s=set(t)
ppow = []
lent = len(t)
i = 0
while  i<lent and t[i]**2<=2*N:
    ppow.append(t[i]**2)
    i+=1
ans = 0

for p in ppow:
    for j in range(lent):
        if p - t[j] in s and p - t[j]<=N and p <=N and t[j]<=N:
            ans+=1
        if t[j]>=p:
            break
print(ans)
0