結果

問題 No.843 Triple Primes
ユーザー kuuso1kuuso1
提出日時 2019-06-28 21:59:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 298 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 12,012 KB
実行使用メモリ 15,676 KB
最終ジャッジ日時 2023-10-19 17:42:49
合計ジャッジ時間 8,181 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,036 KB
testcase_01 AC 295 ms
15,676 KB
testcase_02 AC 33 ms
10,108 KB
testcase_03 AC 31 ms
10,088 KB
testcase_04 AC 34 ms
10,152 KB
testcase_05 AC 32 ms
10,092 KB
testcase_06 AC 34 ms
10,160 KB
testcase_07 AC 225 ms
14,604 KB
testcase_08 AC 250 ms
15,008 KB
testcase_09 AC 280 ms
15,644 KB
testcase_10 AC 233 ms
14,776 KB
testcase_11 AC 257 ms
15,228 KB
testcase_12 AC 273 ms
15,524 KB
testcase_13 AC 270 ms
15,376 KB
testcase_14 AC 269 ms
15,384 KB
testcase_15 AC 229 ms
14,676 KB
testcase_16 AC 250 ms
14,740 KB
testcase_17 AC 30 ms
10,036 KB
testcase_18 AC 29 ms
10,036 KB
testcase_19 AC 29 ms
10,036 KB
testcase_20 AC 92 ms
11,436 KB
testcase_21 AC 61 ms
10,696 KB
testcase_22 AC 166 ms
13,244 KB
testcase_23 AC 164 ms
13,368 KB
testcase_24 AC 93 ms
11,496 KB
testcase_25 AC 79 ms
11,228 KB
testcase_26 AC 294 ms
15,628 KB
testcase_27 AC 42 ms
10,344 KB
testcase_28 AC 270 ms
15,428 KB
testcase_29 AC 100 ms
11,572 KB
testcase_30 AC 272 ms
15,552 KB
testcase_31 AC 56 ms
10,472 KB
testcase_32 AC 40 ms
10,316 KB
testcase_33 AC 109 ms
11,696 KB
testcase_34 AC 158 ms
12,996 KB
testcase_35 AC 298 ms
15,644 KB
testcase_36 AC 73 ms
10,876 KB
testcase_37 AC 248 ms
14,436 KB
testcase_38 AC 195 ms
13,768 KB
testcase_39 AC 271 ms
15,476 KB
testcase_40 AC 30 ms
10,036 KB
testcase_41 AC 30 ms
10,036 KB
testcase_42 AC 259 ms
14,876 KB
testcase_43 AC 273 ms
15,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
from sys import exit
##  input functions for me
def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##

## main ##

N = ri()
isPrime = [True] * (N + 1)
isPrime[0] = False
isPrime[1] = False
P = []
for i in range(2,N+1):
    if not isPrime[i]: continue
    P.append(i)
    for j in range(i + i, N + 1, i): isPrime[j] = False

ans = 0
if N == 1:
    print(0)
    exit(0)

for r in P:
    p = 2
    q = r * r - p
    if q >= 0 and q <= N and isPrime[q]: ans += 2

ans -= 1
print (ans)


    

0