結果

問題 No.843 Triple Primes
ユーザー mlihua09mlihua09
提出日時 2020-09-18 16:47:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 520 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 94,224 KB
最終ジャッジ日時 2023-09-04 08:56:18
合計ジャッジ時間 9,572 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
91,460 KB
testcase_01 AC 170 ms
93,776 KB
testcase_02 AC 107 ms
91,728 KB
testcase_03 AC 108 ms
92,260 KB
testcase_04 AC 106 ms
91,880 KB
testcase_05 AC 108 ms
91,920 KB
testcase_06 AC 107 ms
91,720 KB
testcase_07 AC 154 ms
93,464 KB
testcase_08 AC 158 ms
93,568 KB
testcase_09 AC 171 ms
93,892 KB
testcase_10 AC 155 ms
93,896 KB
testcase_11 AC 161 ms
93,952 KB
testcase_12 AC 166 ms
94,128 KB
testcase_13 AC 166 ms
93,644 KB
testcase_14 AC 164 ms
94,184 KB
testcase_15 AC 155 ms
93,328 KB
testcase_16 AC 154 ms
93,736 KB
testcase_17 AC 97 ms
91,100 KB
testcase_18 AC 97 ms
91,948 KB
testcase_19 AC 99 ms
91,392 KB
testcase_20 AC 118 ms
92,412 KB
testcase_21 AC 112 ms
92,000 KB
testcase_22 AC 134 ms
92,732 KB
testcase_23 AC 137 ms
92,836 KB
testcase_24 AC 118 ms
92,524 KB
testcase_25 AC 113 ms
91,856 KB
testcase_26 AC 168 ms
94,020 KB
testcase_27 AC 107 ms
91,972 KB
testcase_28 AC 165 ms
93,872 KB
testcase_29 AC 122 ms
92,560 KB
testcase_30 AC 170 ms
94,224 KB
testcase_31 AC 109 ms
92,304 KB
testcase_32 AC 109 ms
91,936 KB
testcase_33 AC 121 ms
91,988 KB
testcase_34 AC 135 ms
92,712 KB
testcase_35 AC 171 ms
93,984 KB
testcase_36 AC 116 ms
92,444 KB
testcase_37 AC 154 ms
93,260 KB
testcase_38 AC 144 ms
92,604 KB
testcase_39 AC 168 ms
93,568 KB
testcase_40 AC 101 ms
91,436 KB
testcase_41 AC 99 ms
91,536 KB
testcase_42 AC 157 ms
93,928 KB
testcase_43 AC 164 ms
93,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


isprime = [0, 0] + [1] * (10 ** 6 - 1)

for i in range(2, 10 ** 3 + 1):
    
    if isprime[i]:
        
        for j in range(2 * i, 10 ** 6 + 1, i):
            
            isprime[j] = 0
            
ans = 0

N = int(input())

P = [i for i in range(2, N + 1) if isprime[i]]

from bisect import bisect

for i in range(bisect(P, int((2 * N) ** 0.5))):
    
    for p in P:
        
        if P[i] ** 2 - N <= p < P[i] ** 2 and isprime[P[i] ** 2 - p]:
            
            ans += 1
            

print(ans)
    
0